Skip to content
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

Allow __getattr__ during semantic analysis #5295

Merged
merged 4 commits into from Jun 29, 2018

Conversation

Projects
None yet
2 participants
@ilevkivskyi
Copy link
Collaborator

ilevkivskyi commented Jun 28, 2018

Previously module __getattr__ was used during type checking (runtime context). But it was only partially allowed in semantic analysis (after from a import A, A can be used in annotations/base classes). This PR allows the same support for a.A, i.e. it can be used in annotations and base classes (provided __getattr__ has a suitable return type Any).

@ilevkivskyi ilevkivskyi requested a review from msullivan Jun 28, 2018

@msullivan
Copy link
Collaborator

msullivan left a comment

Looks good.

Are these bugs run into working on sqlalchemy typing?

v = Var(name, type=typ)
v._fullname = name
n = SymbolTableNode(GDEF, v)
names[name] = n

This comment has been minimized.

@msullivan

msullivan Jun 29, 2018

Collaborator

It might be worth pulling this out into another method, since it is a big chunk of code for an obscure case.

This comment has been minimized.

@ilevkivskyi

ilevkivskyi Jun 29, 2018

Author Collaborator

Makes sense. I there is also similar code above in visit_import_from, it would make sense to combine the two into a helper method. I will do this tomorrow.

@ilevkivskyi

This comment has been minimized.

Copy link
Collaborator Author

ilevkivskyi commented Jun 29, 2018

Are these bugs run into working on sqlalchemy typing?

Yes. I am slowly moving through existing stubs and trying to combine them with some __getattr__s to make a "partial" package.

@ilevkivskyi

This comment has been minimized.

Copy link
Collaborator Author

ilevkivskyi commented Jun 29, 2018

testpr is also clean so I am merging now.

@ilevkivskyi ilevkivskyi merged commit d91efd4 into python:master Jun 29, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@ilevkivskyi ilevkivskyi deleted the ilevkivskyi:getattr-semanal branch Jun 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.