-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-error-reportingHow we report errorsHow we report errors
Description
Bug Report
When reporting a "Unexpected keyword argument" error for an initializer, the note can incorrectly reference builtins.pyi instead of the class definition.
To Reproduce
https://mypy-play.net/?gist=b50a11afee5d039fb382667dee8b529f
class Foo:
bar: str
def f() -> Foo:
foo = Foo(bar="bar")
return foo
f()For context, I was using pydantic, but forgot to make the class in question inherit from pydantic.BaseModel. But this isn't specific to pydantic.
Expected Behavior
The note should include the class definition, not an incorrect link to builtins.pyi.
This was misleading because I thought my class was shadowing a built-in one, so I tried renaming it.
Actual Behavior
main.py:5: error: Unexpected keyword argument "bar" for "Foo" [call-arg]
/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "Foo" defined here
I believe the line referenced here is for object.__init__().
Your Environment
- Mypy version used: 1.19.1
- Mypy command-line flags: n/a
- Mypy configuration options from
mypy.ini(and other config files): n/a (default for mypy playground) - Python version used: python3.12
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-error-reportingHow we report errorsHow we report errors