You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
stubtest treats constructors of native types as (self, *args, **kwargs). #17672
TLDR: If you have a zero-arg constructor of a native type, stubtest complains that stub does not have *args argument "args".
From what I understand, constructors of native types will always have a __textsignature__ of __init__($self, /, *args, **kwargs). Instead, the constructor's signature is actually stored on the type's__textsignature__.
However, stubtest never reads the type's signature, and so treats all native constructors as having a (self, *args, **kwargs) constructor. Most of the time this doesn't matter, as _verify_signature allows the stub's type signature to be more precise than the runtime one. However, if the stub's constructor takes no arguments, then we get an error.
To Reproduce
Create the following "foo.py" and "foo.pyi"
# In foo.py:SomeType=object# In foo.pyi:classSomeType:
def__init__(self): ...
Then run stubtest with stubtest foo.
Expected Behaviour
I would expect this to use the type's signature, and not produce any error.
Actual Behaviour
Instead, we get an error about a missing *args:
error: foo.SomeType.__init__ is inconsistent, stub does not have *args argument "args"
Stub: in file foo.pyi:2
None
Runtime:
def (self, /, *args, **kwargs)
Found 1 error (checked 1 module)
Your Environment
Mypy version used: 1.11.1
Mypy command-line flags: None
Mypy configuration options from mypy.ini (and other config files): None
Activity
tungol commentedon Aug 24, 2025
This can be closed as resolved by #18259
brianschubert commentedon Aug 24, 2025
Thanks!
SquidDev commentedon Aug 24, 2025
Amazing, thank you!