Skip to content

Allow instances of a class to access inner class definitions on that class. #3636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 30, 2017

Conversation

rowillia
Copy link
Contributor

This fixes #3635

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@emmatyping
Copy link
Member

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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! Added those tests in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when accessing attribute of inner class
4 participants