Allow instances of a class to access inner class definitions on that class. - #3636
Conversation
ilevkivskyi
left a comment
There was a problem hiding this comment.
The solution is a bit hacky, since it seems to me such things should be done in semanal.py, but maybe there will be other problems, so that I am fine with this.
|
I too had similar concerns on further consideration, however, I cannot think of another case where an inner class might cause issues like this. Though I suppose not considering uses of inner classes is exactly what caused the bug. I think it would be better to fix semanal, as it would avoid potential future issues. Also I don't like the idea of mypy "lying" about the type, as it makes the code harder to understand unless you are familiar with this hack. |
|
|
||
| reveal_type(Foo.Meta.name) # E: Revealed type is 'builtins.str' | ||
| reveal_type(Foo().meta.name) # E: Revealed type is 'builtins.str' | ||
| reveal_type(Foo().Meta.name) # E: Revealed type is 'builtins.str' |
There was a problem hiding this comment.
Why not test Foo.meta.name too?
And what will the types of Foo.Meta, Foo().Meta, Foo.meta and Foo().meta be revealed to be?
There was a problem hiding this comment.
Thanks for the feedback! Added those tests in.
This fixes #3635