Skip to content

Confusing note if Mypy cannot find __init__ of a class #4132

Closed
@Zac-HD

Description

@Zac-HD

This is another entry in the genre of confusing interactions between Mypy and attrs, extracted from #2088 by request of @gvanrossum. Let's start with an example:

import attr
@attr.s()
class A:
    arg = attr.ib()
A(arg=1)
$ python -m mypy --ignore-missing-imports a.py
a.py:5: error: Unexpected keyword argument "arg" for "A"
Lib/mypy/typeshed/stdlib/3/builtins.pyi:39: note: "A" defined here

Mypy can't find A.__init__, so it points to the stub for object.__init__... but misreports it as the definition of A.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions