You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My guess is, because of def __class_getitem__(…) (which seems to be for generics and stuff), the IDE thinks we'll wanna use the class' getitem, i.e. instance.__class__[…].
So the IDE should ignore pydantic's BaseModel.__class_getitem__ when checking for that.
luckydonald
changed the title
IDE doesn't warn for subscripable
IDE does no longer warn for non-subscripable
Jun 19, 2024
Encountered it as well when covnverting a TypedDict to a BaseModel. I missed to parts which still treated it as a typed dict because I didn't get any warning :(
I created my own class and implemented __class_getitem__. Pycharm understood it correctly and gave me the warnings.. It seems like a genuine bug in the plugin.
Describe the bug
The IDE doesn't warn when there's a index/keyword lookup operation.
Take this example:
Notice how the IDE doesn't warn for the use of
['foo']
.However, the result is
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Compare that to how the IDE handles a normal class:
Notice how the IDE complains about the use of
['foo']
here.Screenshots
![image](https://private-user-images.githubusercontent.com/2737108/340226177-ccfd67da-981a-4cf9-90c8-fd10da8b075e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3ODk3NjAsIm5iZiI6MTczOTc4OTQ2MCwicGF0aCI6Ii8yNzM3MTA4LzM0MDIyNjE3Ny1jY2ZkNjdkYS05ODFhLTRjZjktOTBjOC1mZDEwZGE4YjA3NWUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTdUMTA1MTAwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NTUxOWU3ZmFjNDk3Y2NmYzM3ZDk1OTg0Njg4MTcxOWUyZjA1ZWZmOTg1ZmNjNTExYTZhNmJlZTE0OGM3ZWQwYSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.zy6l1VrNC9maOmFZpSy-3eFRYIcmFTHsEUvIpYbwQ7g)
It marks only the second
['foo']
as error.Environments (please complete the following information):
Additional context
Mypy has this correctly, but so should the IDE.
The text was updated successfully, but these errors were encountered: