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

New semantic analyzer: Fix --disallow-untyped-defs with attrs plugin and forward references #6724

Merged
merged 7 commits into from
Apr 26, 2019

Conversation

ilevkivskyi
Copy link
Member

@ilevkivskyi ilevkivskyi commented Apr 25, 2019

The fix essentially mirrors the one for dataclasses. Note I temporary add final_iteration to the old analyzer, because plugin files import everything from the old one.

The non-trivial part is removing previously generated functions in plugins to make them re-entrant.

@ilevkivskyi
Copy link
Member Author

Actually, it looks like the guard against final iteration is not necessary, I am going to remove it for now.

@ilevkivskyi
Copy link
Member Author

Oh, it is actually needed, I just run the tests without NEWSEMANAL=1.

@ilevkivskyi
Copy link
Member Author

The test failures are actually hard to fix. They highlight a problem with all plugins that use add_method() -- they are not re-entrant. The add_method() calls .append() on class body that causes multiple functions with same name added if there is any deferral in the file. I am surprised no tests failed because of this before.

Copy link
Collaborator

@msullivan msullivan left a comment

Choose a reason for hiding this comment

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

This is solid for a bugfix but I think we need to consider if there is a cleaner way to allow plugins to handle these issues. Explicitly checking for the new analyzer and explicitly checking final_iteration are pretty nitty-gritty details that we don't want to have to inflict everywhere.

@ilevkivskyi
Copy link
Member Author

Explicitly checking for the new analyzer and explicitly checking final_iteration are pretty nitty-gritty details that we don't want to have to inflict everywhere.

Yes. One of this will go after the new one is the default. For the second one, possible option is to have defer_if_possible(). It will be actually useful in general, I think we already use this pattern in several places in semantic analyzer. I will create an issue for this.

@ilevkivskyi
Copy link
Member Author

@msullivan Opened #6725

@ilevkivskyi ilevkivskyi merged commit dadae5f into python:master Apr 26, 2019
@ilevkivskyi ilevkivskyi deleted the fix-attrs-newan branch April 26, 2019 02:02
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