Skip to content

"<function> defined here" notes omitted when function is loaded from cache #4772

Open
@msullivan

Description

@msullivan

mypy emits a nice " defined here" note when calling a function with unexpected keywords arguments.

Unfortunately the note is omitted if the module the function is defined in has been loaded from the cache.
This both eliminates a nice message (which we should add more of!) and causes annoying deviations between modes.

The following coarse-grained incremental test fails

[case testCachedUnexpectedKeywordArgument]
import a
[file a.py]
import b
b.lol(uhhhh=12) # tweak
[file a.py.2]
import b
b.lol(uhhhh=12)
[file b.py]
def lol() -> None: pass
[out]
tmp/a.py:2: error: Unexpected keyword argument "uhhhh" for "lol"
tmp/b.py:1: note: "lol" defined here
[out2]
tmp/a.py:2: error: Unexpected keyword argument "uhhhh" for "lol"
tmp/b.py:1: note: "lol" defined here

As well as this fine-grained incremental test:

[case testUnexpectedKeywordArgument]
import a
[file a.py]
import b
[file a.py.2]
import b
b.lol(uhhhh=12)
[file b.py]
def lol() -> None: pass
[out]
==
a.py:2: error: Unexpected keyword argument "uhhhh" for "lol"
b.py:1: note: "lol" defined here

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions