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

using attrs pre-commit mypy error: Unexpected keyword argument [call-arg] #17735

Closed
sebasouza opened this issue Sep 4, 2024 · 1 comment
Closed
Labels
bug mypy got something wrong

Comments

@sebasouza
Copy link

sebasouza commented Sep 4, 2024

mypy runs perfectly on terminal, but when running on pre-commit stage, I am getting the error Unexpected keyword argument for every property in my class

from attrs import define, field
@define(
    frozen=True,
    kw_only=True,
    slots=True,
    auto_detect=True,
    order=False,
    auto_attribs=True,
)
class MyClass:
   a: str = field(default="")
   b: str = field(default="")

   def myMethod(self) -> Any:
     return MyClass(a=self.a, b="b_value") 

mypy pre-commit failed:

error: Unexpected keyword argument "a" for MyClass (line: return MyClass...)

error: Unexpected keyword argument "b" for MyClass (line: return MyClass...)

.pre-commit-config.yaml:

 - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.11.2
    hooks:
      - id: mypy
        args: ["--config-file", "mypy.ini"]
@sebasouza sebasouza added the bug mypy got something wrong label Sep 4, 2024
@sebasouza
Copy link
Author

sebasouza commented Sep 9, 2024

solved with this:

- repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.11.2
    hooks:
      - id: mypy
        additional_dependencies: [attrs]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant