Closed ckarnell closed 4 years ago
This is actually caused by mypy issue https://github.com/python/mypy/issues/7724. But I will keep this open as an important example.
Actually there is a dedicated issue already for this case https://github.com/python/mypy/issues/5481, so this can be closed as a duplicate.
Currently when you access an attribute on a model, its type gets converted to the expected Python type. However, since this uses the plugin hook for attribute access, that means when structural typing is attempted, it doesn't match up.
Here's an example illustrating my point.
Even though
reveal_type(user.id)
showsint
.