-
-
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 errorstopic-incremental
Description
This is a follow-up for #20635
Currently we do not serialize .definition of a CallableType and instead set it in fixup.py if the type appears as a type of a function. This is because there is a reference cycle definition <-> type, and handling it "properly" would require some complications similar to e.g. Instance <-> TypeInfo. However, the current logic causes inconsistencies in error reporting in relative locations. For example, this test fails on second run.
[case testCachedUnexpectedKeywordArgumentAlias]
import a
[file a.py]
import b
b.lol2(uhhhh=12) # tweak
[file a.py.2]
import b
b.lol2(uhhhh=12)
[file b.py]
def lol() -> None: pass
lol2 = lol
[out]
tmp/a.py:2: error: Unexpected keyword argument "uhhhh"
tmp/b.py:1: note: Called function defined here
[out2]
tmp/a.py:2: error: Unexpected keyword argument "uhhhh"
tmp/b.py:1: note: Called function defined here
Same problem also affects our partial plugin. We should either handle .definition "properly" (which may be a big change), or just erase it when aliasing CallableTypes (which will make errors potentially less helpful).
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-error-reportingHow we report errorsHow we report errorstopic-incremental