Describe the bug
The IDE doesn't warn when there's a index/keyword lookup operation.
Take this example:
from pydantic import BaseModel
class SomeModel(BaseModel):
foo: str
instance = SomeModel(foo='fooo')
y1 = instance['foo']
Notice how the IDE doesn't warn for the use of ['foo']
.
However, the result is
TypeError: 'SomeModel' object is not subscriptable
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Compare that to how the IDE handles a normal class:
class NotAPydanticModel(object):
foo: str
instance = NotAPydanticModel()
y2 = instance['foo']
Notice how the IDE complains about the use of ['foo']
here.
Screenshots
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.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too