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
It seems that when the implementation defines a function (not inside a class) with a parameter that has double leading underscore, it can become impossible to type for stubtest. See the following example in SQLAlchemy: python/typeshed#9596 (comment)
(A clear and concise description of what the bug is.)
To Reproduce
In typeshed: python .\tests\stubtest_third_party.py sqlalchemy
with the following stub definitions:
# sqlalchemy.testing.utildefresolve_lambda(__fn, **kw): ...
# sqlalchemy.orm.collectionsclassMappedCollection(dict[_KT, _VT]):
# [...]# This function is actually defined dynamically outside the class@overloaddefupdate(self, __other: SupportsKeysAndGetItem[_KT, _VT], **kwargs: _VT) ->None: ...
@overloaddefupdate(self, __other: Iterable[tuple[_KT, _VT]], **kwargs: _VT) ->None: ...
@overloaddefupdate(self, __other: symbol|_symbol= ..., **kwargs: _VT) ->None: ...
Expected Behavior
No errors
Actual Behavior
error: sqlalchemy.orm.collections.MappedCollection.update is inconsistent, stub argument "__other" differs from runtime argument "__other"
Stub: at line 127 in file E:\Users\Avasam\Documents\Git\typeshed\stubs\sqlalchemy\sqlalchemy\orm\collections.pyi
Overload(def (self: sqlalchemy.orm.collections.MappedCollection[_KT`1, _VT`2], _typeshed.SupportsKeysAndGetItem[_KT`1, _VT`2], **kwargs: _VT`2), def (self: sqlalchemy.orm.collections.MappedCollection[_KT`1, _VT`2], typing.Iterable[Tuple[_KT`1, _VT`2]], **kwargs: _VT`2), def (self: sqlalchemy.orm.collections.MappedCollection[_KT`1, _VT`2], Union[sqlalchemy.util.langhelpers.symbol, sqlalchemy.util.langhelpers._symbol] =, **kwargs: _VT`2))
Inferred signature: def (self: sqlalchemy.orm.collections.MappedCollection[_KT`1, _VT`2], __other: Union[_typeshed.SupportsKeysAndGetItem[_KT`1, _VT`2], typing.Iterable[Tuple[_KT`1, _VT`2]], sqlalchemy.util.langhelpers.symbol, sqlalchemy.util.langhelpers._symbol] = ..., **kwargs)
Runtime: at line 1402 in file C:\Users\Avasam\AppData\Local\Temp\tmpfa40k4ao\lib\site-packages\sqlalchemy\orm\collections.py
def (self, __other=symbol('Unspecified'), **kw)
error: sqlalchemy.orm.collections.MappedCollection.update is inconsistent, stub argument "__other" should be positional or keyword (remove leading double underscore)
Stub: at line 127 in file E:\Users\Avasam\Documents\Git\typeshed\stubs\sqlalchemy\sqlalchemy\orm\collections.pyi
Overload(def (self: sqlalchemy.orm.collections.MappedCollection[_KT`1, _VT`2], _typeshed.SupportsKeysAndGetItem[_KT`1, _VT`2], **kwargs: _VT`2), def (self: sqlalchemy.orm.collections.MappedCollection[_KT`1, _VT`2], typing.Iterable[Tuple[_KT`1, _VT`2]], **kwargs: _VT`2), def (self: sqlalchemy.orm.collections.MappedCollection[_KT`1, _VT`2], Union[sqlalchemy.util.langhelpers.symbol, sqlalchemy.util.langhelpers._symbol] =, **kwargs: _VT`2))
Inferred signature: def (self: sqlalchemy.orm.collections.MappedCollection[_KT`1, _VT`2], __other: Union[_typeshed.SupportsKeysAndGetItem[_KT`1, _VT`2], typing.Iterable[Tuple[_KT`1, _VT`2]], sqlalchemy.util.langhelpers.symbol, sqlalchemy.util.langhelpers._symbol] = ..., **kwargs)
Runtime: at line 1402 in file C:\Users\Avasam\AppData\Local\Temp\tmpfa40k4ao\lib\site-packages\sqlalchemy\orm\collections.py
def (self, __other=symbol('Unspecified'), **kw)
error: sqlalchemy.testing.resolve_lambda is inconsistent, stub argument "__fn" differs from runtime argument "__fn"
Stub: at line 28 in file E:\Users\Avasam\Documents\Git\typeshed\stubs\sqlalchemy\sqlalchemy\testing\__init__.pyi
None
Runtime: at line 322 in file C:\Users\Avasam\AppData\Local\Temp\tmpfa40k4ao\lib\site-packages\sqlalchemy\testing\util.py
def (__fn, **kw)
error: sqlalchemy.testing.resolve_lambda is inconsistent, stub argument "__fn" should be positional or keyword (remove leading double underscore)
Stub: at line 28 in file E:\Users\Avasam\Documents\Git\typeshed\stubs\sqlalchemy\sqlalchemy\testing\__init__.pyi
None
Runtime: at line 322 in file C:\Users\Avasam\AppData\Local\Temp\tmpfa40k4ao\lib\site-packages\sqlalchemy\testing\util.py
def (__fn, **kw)
error: sqlalchemy.testing.util.resolve_lambda is inconsistent, stub argument "__fn" differs from
runtime argument "__fn"
Stub: at line 28 in file E:\Users\Avasam\Documents\Git\typeshed\stubs\sqlalchemy\sqlalchemy\testing\util.pyi
None
Runtime: at line 322 in file C:\Users\Avasam\AppData\Local\Temp\tmpfa40k4ao\lib\site-packages\sqlalchemy\testing\util.py
def (__fn, **kw)
error: sqlalchemy.testing.util.resolve_lambda is inconsistent, stub argument "__fn" should be positional or keyword (remove leading double underscore)
Stub: at line 28 in file E:\Users\Avasam\Documents\Git\typeshed\stubs\sqlalchemy\sqlalchemy\testing\util.pyi
None
Runtime: at line 322 in file C:\Users\Avasam\AppData\Local\Temp\tmpfa40k4ao\lib\site-packages\sqlalchemy\testing\util.py
def (__fn, **kw)
Found 6 errors (checked 228 modules)
Your Environment
Mypy version used: mypy 0.991 (compiled: yes)
Mypy command-line flags: (from typeshed, see above)
Mypy configuration options from mypy.ini (and other config files): (from typeshed, see above)
Python version used: Python 3.9.13
The text was updated successfully, but these errors were encountered:
Bug Report
It seems that when the implementation defines a function (not inside a class) with a parameter that has double leading underscore, it can become impossible to type for stubtest. See the following example in SQLAlchemy: python/typeshed#9596 (comment)
(A clear and concise description of what the bug is.)
To Reproduce
In typeshed:
python .\tests\stubtest_third_party.py sqlalchemy
with the following stub definitions:
Expected Behavior
No errors
Actual Behavior
Your Environment
mypy.ini
(and other config files): (from typeshed, see above)The text was updated successfully, but these errors were encountered: