Skip to content

New semantic analyzer: support default decorators in attrs #6953

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

Closed
ilevkivskyi opened this issue Jun 7, 2019 · 0 comments · Fixed by #7083
Closed

New semantic analyzer: support default decorators in attrs #6953

ilevkivskyi opened this issue Jun 7, 2019 · 0 comments · Fixed by #7083
Assignees
Labels
bug mypy got something wrong priority-0-high semantic-analyzer Problems that happen during semantic analysis topic-attrs topic-plugins The plugin API and ideas for new plugins

Comments

@ilevkivskyi
Copy link
Member

Currently this test case fails

[case testAttrsDefaultDecorator]
defer: Yes

import attr
@attr.s
class C(object):
    x: int = attr.ib(default=1)
    y: int = attr.ib()
    @y.default
    def inc(self):
        return self.x + 1

class Yes: ...
[builtins fixtures/list.pyi]

with

main:7: error: Non-default attributes not allowed after default attributes.

See also #6438

@ilevkivskyi ilevkivskyi added bug mypy got something wrong priority-1-normal topic-plugins The plugin API and ideas for new plugins topic-attrs semantic-analyzer Problems that happen during semantic analysis labels Jun 7, 2019
@ilevkivskyi ilevkivskyi self-assigned this Jun 26, 2019
ilevkivskyi added a commit that referenced this issue Jun 27, 2019
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-0-high semantic-analyzer Problems that happen during semantic analysis topic-attrs topic-plugins The plugin API and ideas for new plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants