Skip to content

New semantic analyser: Fix special attrs decorators #7083

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 27, 2019

Conversation

ilevkivskyi
Copy link
Member

Fixes #6953

I first thought about actually not modifying them in attrs plugin, but this is non-trivial, plus there are few places apart from the plugin where we modify decorators. So for now I just restore them after each iteration (in the same way we do this for overloads and other things).

@ilevkivskyi ilevkivskyi requested a review from JukkaL June 27, 2019 15:03
Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

This looks like a good fix, since this makes each iteration behave more similarly. I only have one comment about possible new test cases (up to you).

@@ -1049,3 +1049,18 @@ class B: # E: Function is missing a type annotation for one or more arguments

reveal_type(B) # N: Revealed type is 'def (x: Any) -> __main__.B'
[builtins fixtures/list.pyi]

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you check that there are tests that run multiple semantic passes with various kinds of decorators? There is a small risk that this might break something.

Copy link
Member Author

Choose a reason for hiding this comment

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

I run all test cases where top-levels processed twice (second time gives an extra iteration). I have found no failures related to this change. I however added another attrs specific decorator test case just in case.

@ilevkivskyi ilevkivskyi merged commit 9152182 into python:master Jun 27, 2019
@ilevkivskyi ilevkivskyi deleted the fix-attrs-deco branch June 27, 2019 16:41
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.

New semantic analyzer: support default decorators in attrs
2 participants