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

Don't expand global variables in body of a function with constrained type variables #9882

Merged
merged 2 commits into from
Jan 6, 2021

Conversation

ilevkivskyi
Copy link
Member

See first test case for the scenario where this causes issues (the second test case is already handled elsewhere and just added for completeness). This is an old issue, but it is important to fix it now because recent changes to PEP 484 about re-export force people to use function aliases.

@ilevkivskyi ilevkivskyi requested a review from JukkaL January 6, 2021 13:02
# a trivial copy, or do something completely different? See
# testGenericFunctionAliasExpand for an example where this is important.
if original.kind != GDEF:
target = self.visit_var(target)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you remove visit_mypy_file from the class (I think that it's unused), this will be completely reasonable, since this will be reference to something outside the AST node we are transforming.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe also update the docstring that this can only be used to transform functions or classes, not top-level statements and such.

@ilevkivskyi ilevkivskyi merged commit 28f92ac into python:master Jan 6, 2021
@ilevkivskyi ilevkivskyi deleted the fix-gen-func-alias branch January 6, 2021 16:19
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.

2 participants