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

mypy attrs plugin doesn't work with new attrs' kw_only argument #6083

Closed
quinor opened this issue Dec 18, 2018 · 1 comment
Closed

mypy attrs plugin doesn't work with new attrs' kw_only argument #6083

quinor opened this issue Dec 18, 2018 · 1 comment

Comments

@quinor
Copy link

quinor commented Dec 18, 2018

Copied from python-attrs/attrs#473 - issue concerns both parties...

$ python -m mypy --version
mypy 0.650
>>> attr.__version__
'18.2.0'

Use mypy on following file:

import typing
import attr


@attr.s(frozen=True, auto_attribs=True, kw_only=True)
class Position:
    line: int
    column: int


@attr.s(frozen=True, auto_attribs=True, kw_only=True)
class Node:
    start: typing.Optional[Position] = None
    end: typing.Optional[Position] = None


@attr.s(frozen=True, auto_attribs=True, kw_only=True)
class Operator(Node):
    symbol: str
    name: str
    precedence: int
    associativity: str  # "left" or "right"

It gives following errors:

f.py:21: error: Non-default attributes not allowed after default attributes.
f.py:22: error: Non-default attributes not allowed after default attributes.
f.py:23: error: Non-default attributes not allowed after default attributes.
f.py:24: error: Non-default attributes not allowed after default attributes.

If I understand correctly, mypy doesn't consider the existence of a new kw_only=True .

@ilevkivskyi
Copy link
Member

It will be great to support this in mypy. Shouldn't be too hard to implement, but may be tedious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants