Skip to content

New semantic analyser: Fix special attrs decorators#7083

Merged
ilevkivskyi merged 2 commits intopython:masterfrom
ilevkivskyi:fix-attrs-deco
Jun 27, 2019
Merged

New semantic analyser: Fix special attrs decorators#7083
ilevkivskyi merged 2 commits intopython:masterfrom
ilevkivskyi:fix-attrs-deco

Conversation

@ilevkivskyi
Copy link
Copy Markdown
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
Copy Markdown
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).


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

Copy link
Copy Markdown
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
Copy Markdown
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