Skip to content

Call plugin get_attribute_hook() also for attributes that trigger __getattr__() #6259

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

Closed
ilevkivskyi opened this issue Jan 28, 2019 · 0 comments
Labels
priority-1-normal topic-plugins The plugin API and ideas for new plugins topic-usability

Comments

@ilevkivskyi
Copy link
Member

Currently, get_attribute_hook() is only called for attributes that are already present in the class symbol table. However, the typical use case is opposite -- dynamically added attributes. Therefore, the current behavior creates some complications while developing plugins, like every access to dynamic attribute first requires somehow placing it into the class symbol table using other hooks. I propose to widen the scope of get_attribute_hook() to at least be called for classes with __getattr__().

@ilevkivskyi ilevkivskyi added priority-1-normal topic-usability topic-plugins The plugin API and ideas for new plugins labels Jan 28, 2019
lincolnq added a commit to lincolnq/mypy that referenced this issue Feb 10, 2019
Whenever we find __getattr__ or __getattribute__ on an instance, the getattribute hook is used.
(It continues to be used whenever we find a method or variable on an instance)

Closes python#6259, python#5910
ilevkivskyi pushed a commit that referenced this issue Feb 10, 2019
Whenever we find `__getattr__` or `__getattribute__` on an instance, the getattribute hook is called to give the hook a chance to modify the return type of one of those functions.

Closes #6259, #5910
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-1-normal topic-plugins The plugin API and ideas for new plugins topic-usability
Projects
None yet
Development

No branches or pull requests

1 participant