-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
RFC: Rework *args parsing
#20472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
RFC: Rework *args parsing
#20472
Conversation
cleanup fix param spec tuple interaction fix self check more cleanup use Unpack for 3.9 / 3.10 tests fixed crash in overload with multiple rvalues fixed basic tuple expression round trip fix bad paramspec interaction with typevartuple reworked star argument checking
|
Diff from mypy_primer, showing the effect of this PR on open source code: beartype (https://github.com/beartype/beartype)
+ beartype/_util/hint/pep/proposal/pep646692.py:418: error: Unused "type: ignore" comment [unused-ignore]
spack (https://github.com/spack/spack)
+ lib/spack/spack/version/version_types.py:134: error: Incompatible types in assignment (expression has type "tuple[str, ...]", variable has type "tuple[str]") [assignment]
optuna (https://github.com/optuna/optuna)
+ optuna/_experimental.py:84: error: Argument 1 has incompatible type "*tuple[Any, ...]"; expected "FP.args" [arg-type]
+ optuna/_deprecated.py:115: error: Argument 1 has incompatible type "*tuple[Any, ...]"; expected "FP.args" [arg-type]
spark (https://github.com/apache/spark)
+ python/pyspark/sql/profiler.py:261: error: Incompatible types in assignment (expression has type "tuple[None, dict[str, list[tuple[int, tuple[float, float, int] | None]]] | None, *tuple[Any, ...]]", target has type "tuple[Stats | None, dict[str, list[tuple[int, tuple[float, float, int] | None]]] | None]") [assignment]
+ python/pyspark/sql/profiler.py:266: error: Incompatible types in assignment (expression has type "tuple[None, dict[str, list[tuple[int, tuple[float, float, int] | None]]] | None, *tuple[Any, ...]]", target has type "tuple[Stats | None, dict[str, list[tuple[int, tuple[float, float, int] | None]]] | None]") [assignment]
+ python/pyspark/sql/profiler.py:286: error: Incompatible types in assignment (expression has type "tuple[Stats | None, None, *tuple[Any, ...]]", target has type "tuple[Stats | None, dict[str, list[tuple[int, tuple[float, float, int] | None]]] | None]") [assignment]
+ python/pyspark/sql/profiler.py:291: error: Incompatible types in assignment (expression has type "tuple[Stats | None, None, *tuple[Any, ...]]", target has type "tuple[Stats | None, dict[str, list[tuple[int, tuple[float, float, int] | None]]] | None]") [assignment]
hydpy (https://github.com/hydpy-dev/hydpy)
+ hydpy/core/selectiontools.py:370: error: Argument 1 to "intersection" of "Devices" has incompatible type "*Elements"; expected "Elements" [arg-type]
+ hydpy/core/pubtools.py:163: error: Argument 1 to "Timegrids" has incompatible type "*Timegrids | Timegrid | tuple[datetime | str | Date, datetime | str | Date, timedelta | str | Period]"; expected "Timegrid" [arg-type]
+ hydpy/core/pubtools.py:163: error: Argument 1 to "Timegrids" has incompatible type "*Timegrids | Timegrid | tuple[datetime | str | Date, datetime | str | Date, timedelta | str | Period]"; expected "Timegrid | None" [arg-type]
tornado (https://github.com/tornadoweb/tornado)
+ tornado/routing.py:355: error: Argument 2 to "Rule" has incompatible type "*list[Any] | tuple[Any] | tuple[Any, dict[str, Any]] | tuple[Any, dict[str, Any], str]"; expected "dict[str, Any] | None" [arg-type]
+ tornado/routing.py:355: error: Argument 2 to "Rule" has incompatible type "*list[Any] | tuple[Any] | tuple[Any, dict[str, Any]] | tuple[Any, dict[str, Any], str]"; expected "str | None" [arg-type]
+ tornado/routing.py:357: error: Argument 1 to "Rule" has incompatible type "*list[Any] | tuple[str | Matcher, Any] | tuple[str | Matcher, Any, dict[str, Any]] | tuple[str | Matcher, Any, dict[str, Any], str]"; expected "Matcher" [arg-type]
+ tornado/routing.py:357: error: Argument 1 to "Rule" has incompatible type "*list[Any] | tuple[str | Matcher, Any] | tuple[str | Matcher, Any, dict[str, Any]] | tuple[str | Matcher, Any, dict[str, Any], str]"; expected "dict[str, Any] | None" [arg-type]
+ tornado/routing.py:357: error: Argument 1 to "Rule" has incompatible type "*list[Any] | tuple[str | Matcher, Any] | tuple[str | Matcher, Any, dict[str, Any]] | tuple[str | Matcher, Any, dict[str, Any], str]"; expected "str | None" [arg-type]
mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ bson/__init__.py:1332: error: Incompatible types in "yield" (actual type "Mapping[str, Any]", expected type "dict[str, Any] | _DocumentType") [misc]
+ bson/__init__.py:1378: error: Argument 2 to "_bson_to_dict" has incompatible type "CodecOptions[_DocumentType] | CodecOptions[dict[str, Any]]"; expected "CodecOptions[Mapping[str, Any]]" [arg-type]
+ bson/__init__.py:1378: note: Error code "arg-type" not covered by "type: ignore" comment
+ pymongo/network_layer.py:107: error: Exception type must be derived from BaseException (or be a tuple of exception classes) [misc]
+ pymongo/network_layer.py:156: error: Exception type must be derived from BaseException (or be a tuple of exception classes) [misc]
+ pymongo/network_layer.py:354: error: Exception type must be derived from BaseException (or be a tuple of exception classes) [misc]
- pymongo/synchronous/topology.py:1077: error: No overload variant of "gather" matches argument types "list[None]", "bool" [call-overload]
+ pymongo/synchronous/topology.py:1077: error: Argument 1 to "gather" has incompatible type "*list[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
- pymongo/synchronous/topology.py:1077: note: Error code "call-overload" not covered by "type: ignore" comment
+ pymongo/synchronous/topology.py:1077: note: Error code "arg-type" not covered by "type: ignore" comment
- pymongo/synchronous/topology.py:1077: note: Possible overload variants:
- pymongo/synchronous/topology.py:1077: note: def [_T1] gather(Future[_T1] | Awaitable[_T1], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1]]
- pymongo/synchronous/topology.py:1077: note: def [_T1, _T2] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2]]
- pymongo/synchronous/topology.py:1077: note: def [_T1, _T2, _T3] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3]]
- pymongo/synchronous/topology.py:1077: note: def [_T1, _T2, _T3, _T4] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4]]
- pymongo/synchronous/topology.py:1077: note: def [_T1, _T2, _T3, _T4, _T5] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], Future[_T5] | Awaitable[_T5], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]
- pymongo/synchronous/topology.py:1077: note: def [_T1, _T2, _T3, _T4, _T5, _T6] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], Future[_T5] | Awaitable[_T5], Future[_T6] | Awaitable[_T6], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]
- pymongo/synchronous/topology.py:1077: note: def [_T] gather(*coros_or_futures: Future[_T] | Awaitable[_T], return_exceptions: Literal[False] = ...) -> Future[list[_T]]
- pymongo/synchronous/topology.py:1077: note: def [_T1] gather(Future[_T1] | Awaitable[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]
- pymongo/synchronous/topology.py:1077: note: def [_T1, _T2] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]
- pymongo/synchronous/topology.py:1077: note: def [_T1, _T2, _T3] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]
- pymongo/synchronous/topology.py:1077: note: def [_T1, _T2, _T3, _T4] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]
- pymongo/synchronous/topology.py:1077: note: def [_T1, _T2, _T3, _T4, _T5] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], Future[_T5] | Awaitable[_T5], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]]
- pymongo/synchronous/topology.py:1077: note: def [_T1, _T2, _T3, _T4, _T5, _T6] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], Future[_T5] | Awaitable[_T5], Future[_T6] | Awaitable[_T6], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException, _T6 | BaseException]]
- pymongo/synchronous/topology.py:1077: note: def [_T] gather(*coros_or_futures: Future[_T] | Awaitable[_T], return_exceptions: bool) -> Future[list[_T | BaseException]]
+ pymongo/synchronous/pool.py:849: error: Argument 1 to "gather" has incompatible type "*list[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ pymongo/synchronous/pool.py:849: note: Error code "arg-type" not covered by "type: ignore" comment
+ pymongo/synchronous/pool.py:886: error: Argument 1 to "gather" has incompatible type "*list[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ pymongo/synchronous/pool.py:886: note: Error code "arg-type" not covered by "type: ignore" comment
+ pymongo/synchronous/pool.py:937: error: Argument 1 to "gather" has incompatible type "*list[None]"; expected "Future[Never] | Awaitable[Never]" [arg-type]
+ pymongo/synchronous/pool.py:937: note: Error code "arg-type" not covered by "type: ignore" comment
- pymongo/synchronous/pool.py:848: error: No overload variant of "gather" matches argument types "list[None]", "bool" [call-overload]
- pymongo/synchronous/pool.py:848: note: Possible overload variants:
- pymongo/synchronous/pool.py:848: note: def [_T1] gather(Future[_T1] | Awaitable[_T1], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1]]
- pymongo/synchronous/pool.py:848: note: def [_T1, _T2] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2]]
- pymongo/synchronous/pool.py:848: note: def [_T1, _T2, _T3] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3]]
- pymongo/synchronous/pool.py:848: note: def [_T1, _T2, _T3, _T4] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4]]
- pymongo/synchronous/pool.py:848: note: def [_T1, _T2, _T3, _T4, _T5] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], Future[_T5] | Awaitable[_T5], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]
- pymongo/synchronous/pool.py:848: note: def [_T1, _T2, _T3, _T4, _T5, _T6] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], Future[_T5] | Awaitable[_T5], Future[_T6] | Awaitable[_T6], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]
- pymongo/synchronous/pool.py:848: note: def [_T] gather(*coros_or_futures: Future[_T] | Awaitable[_T], return_exceptions: Literal[False] = ...) -> Future[list[_T]]
- pymongo/synchronous/pool.py:848: note: def [_T1] gather(Future[_T1] | Awaitable[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]
- pymongo/synchronous/pool.py:848: note: def [_T1, _T2] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]
- pymongo/synchronous/pool.py:848: note: def [_T1, _T2, _T3] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]
- pymongo/synchronous/pool.py:848: note: def [_T1, _T2, _T3, _T4] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]
- pymongo/synchronous/pool.py:848: note: def [_T1, _T2, _T3, _T4, _T5] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], Future[_T5] | Awaitable[_T5], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]]
- pymongo/synchronous/pool.py:848: note: def [_T1, _T2, _T3, _T4, _T5, _T6] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], Future[_T5] | Awaitable[_T5], Future[_T6] | Awaitable[_T6], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException, _T6 | BaseException]]
- pymongo/synchronous/pool.py:848: note: def [_T] gather(*coros_or_futures: Future[_T] | Awaitable[_T], return_exceptions: bool) -> Future[list[_T | BaseException]]
- pymongo/synchronous/pool.py:885: error: No overload variant of "gather" matches argument types "list[None]", "bool" [call-overload]
- pymongo/synchronous/pool.py:885: note: Possible overload variants:
- pymongo/synchronous/pool.py:885: note: def [_T1] gather(Future[_T1] | Awaitable[_T1], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1]]
- pymongo/synchronous/pool.py:885: note: def [_T1, _T2] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2]]
- pymongo/synchronous/pool.py:885: note: def [_T1, _T2, _T3] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3]]
- pymongo/synchronous/pool.py:885: note: def [_T1, _T2, _T3, _T4] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4]]
- pymongo/synchronous/pool.py:885: note: def [_T1, _T2, _T3, _T4, _T5] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], Future[_T5] | Awaitable[_T5], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]
- pymongo/synchronous/pool.py:885: note: def [_T1, _T2, _T3, _T4, _T5, _T6] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], Future[_T5] | Awaitable[_T5], Future[_T6] | Awaitable[_T6], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]
- pymongo/synchronous/pool.py:885: note: def [_T] gather(*coros_or_futures: Future[_T] | Awaitable[_T], return_exceptions: Literal[False] = ...) -> Future[list[_T]]
- pymongo/synchronous/pool.py:885: note: def [_T1] gather(Future[_T1] | Awaitable[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]
- pymongo/synchronous/pool.py:885: note: def [_T1, _T2] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]
- pymongo/synchronous/pool.py:885: note: def [_T1, _T2, _T3] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]
- pymongo/synchronous/pool.py:885: note: def [_T1, _T2, _T3, _T4] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]
- pymongo/synchronous/pool.py:885: note: def [_T1, _T2, _T3, _T4, _T5] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], Future[_T5] | Awaitable[_T5], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]]
- pymongo/synchronous/pool.py:885: note: def [_T1, _T2, _T3, _T4, _T5, _T6] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], Future[_T5] | Awaitable[_T5], Future[_T6] | Awaitable[_T6], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException, _T6 | BaseException]]
- pymongo/synchronous/pool.py:885: note: def [_T] gather(*coros_or_futures: Future[_T] | Awaitable[_T], return_exceptions: bool) -> Future[list[_T | BaseException]]
- pymongo/synchronous/pool.py:936: error: No overload variant of "gather" matches argument types "list[None]", "bool" [call-overload]
- pymongo/synchronous/pool.py:936: note: Possible overload variants:
- pymongo/synchronous/pool.py:936: note: def [_T1] gather(Future[_T1] | Awaitable[_T1], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1]]
- pymongo/synchronous/pool.py:936: note: def [_T1, _T2] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2]]
- pymongo/synchronous/pool.py:936: note: def [_T1, _T2, _T3] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3]]
- pymongo/synchronous/pool.py:936: note: def [_T1, _T2, _T3, _T4] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4]]
- pymongo/synchronous/pool.py:936: note: def [_T1, _T2, _T3, _T4, _T5] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], Future[_T5] | Awaitable[_T5], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]
- pymongo/synchronous/pool.py:936: note: def [_T1, _T2, _T3, _T4, _T5, _T6] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], Future[_T4] | Awaitable[_T4], Future[_T5] | Awaitable[_T5], Future[_T6] | Awaitable[_T6], /, *, return_exceptions: Literal[False] = ...) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]
- pymongo/synchronous/pool.py:936: note: def [_T] gather(*coros_or_futures: Future[_T] | Awaitable[_T], return_exceptions: Literal[False] = ...) -> Future[list[_T]]
- pymongo/synchronous/pool.py:936: note: def [_T1] gather(Future[_T1] | Awaitable[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]
- pymongo/synchronous/pool.py:936: note: def [_T1, _T2] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]
- pymongo/synchronous/pool.py:936: note: def [_T1, _T2, _T3] gather(Future[_T1] | Awaitable[_T1], Future[_T2] | Awaitable[_T2], Future[_T3] | Awaitable[_T3], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]
... (truncated 4 lines) ...
prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/utilities/asyncutils.py:312: error: Argument 1 has incompatible type "*tuple[Any, ...]"; expected "P.args" [arg-type]
- src/prefect/blocks/core.py:86: error: Argument 4 to <tuple> has incompatible type "*tuple[object, ...]"; expected "type" [arg-type]
+ src/prefect/blocks/core.py:86: error: Incompatible types in assignment (expression has type "tuple[type[list[_T]], type[dict[_KT, _VT]], type[tuple[_T_co, ...]], Unpack[tuple[object, ...]]]", variable has type "tuple[type, ...]") [assignment]
+ src/prefect/flow_engine.py:1479: error: Argument 1 has incompatible type "*tuple[Any, ...]"; expected "P.args" [arg-type]
+ src/prefect/flow_engine.py:1520: error: Argument 1 has incompatible type "*tuple[Any, ...]"; expected "P.args" [arg-type]
+ src/prefect/task_engine.py:1718: error: Argument 1 has incompatible type "*tuple[Any, ...]"; expected "P.args" [arg-type]
+ src/prefect/task_engine.py:1776: error: Argument 1 has incompatible type "*tuple[Any, ...]"; expected "P.args" [arg-type]
pydantic (https://github.com/pydantic/pydantic)
- pydantic/_internal/_typing_extra.py:621: error: Too many positional arguments for "ForwardRef" [misc]
+ pydantic/_internal/_typing_extra.py:621: error: Too many positional arguments for "ForwardRef" [call-arg]
- pydantic/_internal/_typing_extra.py:621: error: Argument 2 to "ForwardRef" has incompatible type "bool"; expected "str | None" [arg-type]
- pydantic/dataclasses.py:257: error: Too many arguments [call-arg]
+ pydantic/dataclasses.py:257: error: Too many positional arguments [call-arg]
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/web_urldispatcher.py:644:16: error: Exception type must be derived from BaseException (or be a tuple of exception classes) [misc]
colour (https://github.com/colour-science/colour)
- colour/plotting/models.py:2008: error: Unused "type: ignore" comment [unused-ignore]
mypy (https://github.com/python/mypy)
+ mypy/cache.py:162: error: List comprehension has incompatible type List[tuple[str | int | None, ...]]; expected List[tuple[str | None, int, int, int, int, str, str, str | None]] [misc]
meson (https://github.com/mesonbuild/meson)
+ mesonbuild/interpreter/type_checking.py:945:11: error: Need type annotation for "JAR_KWS" [var-annotated]
zulip (https://github.com/zulip/zulip)
- zerver/tests/test_typed_endpoint.py:76: error: Too many arguments for "Foo" [call-arg]
+ zerver/tests/test_typed_endpoint.py:76: error: Too many positional arguments for "Foo" [call-arg]
- zerver/tests/test_typed_endpoint.py:531: error: Too many arguments for "CustomType" [call-arg]
+ zerver/tests/test_typed_endpoint.py:531: error: Too many positional arguments for "CustomType" [call-arg]
core (https://github.com/home-assistant/core)
+ homeassistant/helpers/device_registry.py:1544: error: Set comprehension has incompatible type Set[tuple[str, ...]]; expected Set[tuple[str, str]] [misc]
+ homeassistant/helpers/device_registry.py:1551: error: Set comprehension has incompatible type Set[tuple[str, ...]]; expected Set[tuple[str, str]] [misc]
- homeassistant/components/light/__init__.py:1155: error: Too many arguments for "color_rgbww_to_rgb" [call-arg]
+ homeassistant/components/light/__init__.py:1155: error: Too many positional arguments for "color_rgbww_to_rgb" [call-arg]
+ homeassistant/components/auth/login_flow.py:333: error: Incompatible types in assignment (expression has type "tuple[str, ...]", variable has type "tuple[str, str]") [assignment]
+ homeassistant/helpers/template/extensions/base.py:54: error: Argument 1 has incompatible type "*_P.args"; expected "Any" [arg-type]
+ homeassistant/components/govee_light_local/light.py:216: error: Argument 2 to "set_rgb_color" of "GoveeLocalApiCoordinator" has incompatible type "*tuple[int, int, int] | tuple[int | None]"; expected "int" [arg-type]
+ homeassistant/components/govee_light_local/light.py:218: error: Argument 2 to "set_temperature" of "GoveeLocalApiCoordinator" has incompatible type "*tuple[int, int, int] | tuple[int | None]"; expected "int" [arg-type]
+ homeassistant/components/bryant_evolution/__init__.py:73: error: Invalid index type "tuple[int, ...]" for "dict[tuple[int, int], Any]"; expected type "tuple[int, int]" [index]
+ homeassistant/components/bryant_evolution/climate.py:46: error: Argument 1 to "get" of "dict" has incompatible type "tuple[int, ...]"; expected "tuple[int, int]" [arg-type]
+ homeassistant/components/blebox/light.py:114: error: Incompatible return value type (got "tuple[int, ...]", expected "tuple[int, int, int] | None") [return-value]
+ homeassistant/components/blebox/light.py:125: error: Incompatible return value type (got "tuple[int, ...]", expected "tuple[int, int, int, int] | None") [return-value]
+ homeassistant/components/blebox/light.py:132: error: Incompatible return value type (got "tuple[int, ...]", expected "tuple[int, int, int, int, int] | None") [return-value]
+ homeassistant/components/knx/light.py:375: error: Incompatible return value type (got "tuple[*tuple[Any, ...], Any]", expected "tuple[int, int, int, int] | None") [return-value]
+ homeassistant/components/shelly/light.py:404: error: Incompatible return value type (got "tuple[*tuple[Any, ...], Any]", expected "tuple[int, int, int, int]") [return-value]
altair (https://github.com/vega/altair)
+ altair/utils/_transformed_data.py:493: error: Argument 1 to "update" of "MutableMapping" has incompatible type "dict[tuple[str, tuple[int, ...]], tuple[str, tuple[int, ...]]]"; expected "SupportsKeysAndGetItem[tuple[Any, tuple[*tuple[int, ...], int]], tuple[Any, tuple[int, ...]]]" [arg-type]
+ altair/utils/_transformed_data.py:496: error: Incompatible return value type (got "dict[tuple[Any, tuple[*tuple[int, ...], int]], tuple[Any, tuple[int, ...]]]", expected "dict[tuple[str, tuple[int, ...]], tuple[str, tuple[int, ...]]]") [return-value]
+ altair/utils/_transformed_data.py:496: note: Perhaps you need a type annotation for "facet_mapping"? Suggestion: "dict[tuple[str, tuple[int, ...]], tuple[str, tuple[int, ...]]]"
scrapy (https://github.com/scrapy/scrapy)
+ scrapy/utils/reactor.py:75: error: Argument 1 has incompatible type "*tuple[Any, ...]"; expected "_P.args" [arg-type]
+ scrapy/utils/asyncio.py:175: error: Argument 1 has incompatible type "*tuple[Any, ...]"; expected "_P.args" [arg-type]
+ scrapy/utils/defer.py:242: error: Argument 2 has incompatible type "*tuple[Any, ...]"; expected "_P.args" [arg-type]
mitmproxy (https://github.com/mitmproxy/mitmproxy)
- mitmproxy/coretypes/multidict.py:153: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/coretypes/multidict.py:167: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/tools/console/grideditor/base.py:168: error: Unused "type: ignore" comment [unused-ignore]
steam.py (https://github.com/Gobot1234/steam.py)
- steam/chat.py:290: error: Too many arguments for "react_to_chat_message" of "ConnectionState" [call-arg]
+ steam/chat.py:290: error: Too many positional arguments for "react_to_chat_message" of "ConnectionState" [call-arg]
- steam/chat.py:318: error: Too many arguments for "ack_chat_message" of "ConnectionState" [call-arg]
+ steam/chat.py:318: error: Too many positional arguments for "ack_chat_message" of "ConnectionState" [call-arg]
+ steam/ext/commands/commands.py:362: error: Argument 2 to "__call__" of "Command" has incompatible type "*tuple[Any, ...]"; expected "P.args" [arg-type]
- steam/ext/commands/commands.py:553: error: Too many arguments for "object" [call-arg]
+ steam/ext/commands/commands.py:553: error: Too many positional arguments for "object" [call-arg]
sympy (https://github.com/sympy/sympy)
+ sympy/matrices/matrixbase.py:3919: error: Incompatible return value type (got "tuple[Expr, ...]", expected "tuple[Expr]") [return-value]
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+ src/hydra_zen/wrapper/_implementations.py:441: error: Argument 1 has incompatible type "*Generator[Any, None, None]"; expected "P.args" [arg-type]
comtypes (https://github.com/enthought/comtypes)
+ comtypes/_memberspec.py:175: error: Argument 3 to "_DispMemberSpec" has incompatible type "tuple[dispid | str, ...]"; expected "tuple[dispid, helpstring, *tuple[str, ...]] | tuple[dispid, *tuple[str, ...]]" [arg-type]
+ comtypes/_memberspec.py:180: error: Argument 3 to "_DispMemberSpec" has incompatible type "tuple[dispid | str, ...]"; expected "tuple[dispid, helpstring, *tuple[str, ...]] | tuple[dispid, *tuple[str, ...]]" [arg-type]
urllib3 (https://github.com/urllib3/urllib3)
+ test/with_dummyserver/test_poolmanager.py:659: error: Unused "type: ignore" comment [unused-ignore]
+ test/with_dummyserver/test_poolmanager.py:659: error: Too many positional arguments for "request" [call-arg]
+ test/with_dummyserver/test_poolmanager.py:659: note: Error code "call-arg" not covered by "type: ignore" comment
egglog-python (https://github.com/egraphs-good/egglog-python)
+ python/egglog/thunk.py:54: error: Incompatible return value type (got "Thunk[T, *tuple[Never, ...]]", expected "Thunk[T]") [return-value]
pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/col.py:52: error: Incompatible return value type (got "tuple[Series, ...]", expected "tuple[Series]") [return-value]
+ pandas/core/common.py:532: error: Argument 2 has incompatible type "*tuple[Any, ...]"; expected "P.args" [arg-type]
+ pandas/core/generic.py:6083: error: Argument 2 to "pipe" has incompatible type "Callable[[Self, **P], T] | tuple[Callable[..., T], str]"; expected "tuple[Callable[..., T], str]" [arg-type]
+ pandas/core/window/rolling.py:1618: error: Argument 2 to "pipe" has incompatible type "Callable[[Self, **P], T] | tuple[Callable[..., T], str]"; expected "tuple[Callable[..., T], str]" [arg-type]
+ pandas/core/window/rolling.py:2350: error: Argument 1 to "pipe" of "RollingAndExpandingMixin" has incompatible type "Callable[[Self, **P], T] | tuple[Callable[..., T], str]"; expected "tuple[Callable[..., T], str]" [arg-type]
+ pandas/core/window/expanding.py:420: error: Argument 1 to "pipe" of "RollingAndExpandingMixin" has incompatible type "Callable[[Self, **P], T] | tuple[Callable[..., T], str]"; expected "tuple[Callable[..., T], str]" [arg-type]
+ pandas/core/groupby/groupby.py:815: error: Argument 2 to "pipe" has incompatible type "Callable[[Self, **P], T] | tuple[Callable[..., T], str]"; expected "tuple[Callable[..., T], str]" [arg-type]
+ pandas/core/resample.py:341: error: Argument 1 to "pipe" of "BaseGroupBy" has incompatible type "Callable[[Self, **P], T] | tuple[Callable[..., T], str]"; expected "tuple[Callable[..., T], str]" [arg-type]
+ pandas/io/formats/style.py:3879: error: Argument 2 to "pipe" has incompatible type "Callable[[Self, **P], T] | tuple[Callable[..., T], str]"; expected "tuple[Callable[..., T], str]" [arg-type]
ibis (https://github.com/ibis-project/ibis)
- ibis/common/collections.py:244: error: Too many arguments for "MapSet" [call-arg]
+ ibis/common/collections.py:244: error: Too many positional arguments for "MapSet" [call-arg]
- ibis/common/collections.py:251: error: Too many arguments for "MapSet" [call-arg]
+ ibis/common/collections.py:251: error: Too many positional arguments for "MapSet" [call-arg]
- ibis/common/collections.py:258: error: Too many arguments for "MapSet" [call-arg]
+ ibis/common/collections.py:258: error: Too many positional arguments for "MapSet" [call-arg]
- ibis/common/collections.py:265: error: Too many arguments for "MapSet" [call-arg]
+ ibis/common/collections.py:265: error: Too many positional arguments for "MapSet" [call-arg]
- ibis/common/collections.py:274: error: Too many arguments for "MapSet" [call-arg]
+ ibis/common/collections.py:274: error: Too many positional arguments for "MapSet" [call-arg]
- ibis/expr/types/generic.py:384: error: Argument 1 to <tuple> has incompatible type "ibis.expr.types.generic.Value"; expected "ibis.expr.operations.core.Value[Any, Any]" [arg-type]
- ibis/expr/types/generic.py:384: error: Argument 2 to <tuple> has incompatible type "*tuple[ibis.expr.types.generic.Value, ...]"; expected "ibis.expr.operations.core.Value[Any, Any]" [arg-type]
+ ibis/expr/types/generic.py:384: error: Argument 1 to "Coalesce" has incompatible type "tuple[ibis.expr.types.generic.Value, *tuple[ibis.expr.types.generic.Value, ...]]"; expected "tuple[ibis.expr.operations.core.Value[Any, Any], ...]" [arg-type]
- ibis/expr/types/generic.py:3167: error: Too many arguments for "Value" [call-arg]
+ ibis/expr/types/generic.py:3167: error: Too many positional arguments for "Value" [call-arg]
- ibis/expr/types/strings.py:1580: error: Argument 1 to <tuple> has incompatible type "StringValue"; expected "Value[String, Any]" [arg-type]
- ibis/expr/types/strings.py:1580: error: Argument 2 to <tuple> has incompatible type "str | StringValue"; expected "Value[String, Any]" [arg-type]
- ibis/expr/types/strings.py:1580: error: Argument 3 to <tuple> has incompatible type "*tuple[str | StringValue, ...]"; expected "Value[String, Any]" [arg-type]
+ ibis/expr/types/strings.py:1580: error: Argument 1 to "StringConcat" has incompatible type "tuple[StringValue, str | StringValue, *tuple[str | StringValue, ...]]"; expected "tuple[Value[String, Any], ...]" [arg-type]
+ ibis/expr/types/arrays.py:226: error: Argument 1 to "ArrayConcat" has incompatible type "tuple[ArrayValue, ArrayValue, *tuple[ArrayValue, ...]]"; expected "tuple[Value[Array[Any], Any], ...]" [arg-type]
- ibis/expr/types/arrays.py:226: error: Argument 1 to <tuple> has incompatible type "ArrayValue"; expected "Value[Array[Any], Any]" [arg-type]
- ibis/expr/types/arrays.py:226: error: Argument 2 to <tuple> has incompatible type "ArrayValue"; expected "Value[Array[Any], Any]" [arg-type]
- ibis/expr/types/arrays.py:226: error: Argument 3 to <tuple> has incompatible type "*tuple[ArrayValue, ...]"; expected "Value[Array[Any], Any]" [arg-type]
+ ibis/expr/types/arrays.py:1014: error: Argument 1 to "ArrayZip" has incompatible type "tuple[ArrayValue, ArrayValue, *tuple[ArrayValue, ...]]"; expected "tuple[Value[Array[Any], Any], ...]" [arg-type]
- ibis/expr/types/arrays.py:1014: error: Argument 1 to <tuple> has incompatible type "ArrayValue"; expected "Value[Array[Any], Any]" [arg-type]
- ibis/expr/types/arrays.py:1014: error: Argument 2 to <tuple> has incompatible type "ArrayValue"; expected "Value[Array[Any], Any]" [arg-type]
- ibis/expr/types/arrays.py:1014: error: Argument 3 to <tuple> has incompatible type "*tuple[ArrayValue, ...]"; expected "Value[Array[Any], Any]" [arg-type]
- ibis/expr/types/relations.py:5177: error: Too many arguments for "WindowedTable" [call-arg]
+ ibis/expr/types/relations.py:5177: error: Too many positional arguments for "WindowedTable" [call-arg]
- ibis/expr/types/logical.py:333: error: Too many arguments for "Any" [call-arg]
+ ibis/expr/types/logical.py:333: error: Too many positional arguments for "Any" [call-arg]
- ibis/backends/sql/compilers/risingwave.py:30: error: Incompatible types in assignment (expression has type "tuple[type[Kurtosis] | type[Sample] | type[ApproxMultiQuantile] | type[MultiQuantile] | type[RandomUUID] | <6 more items>, ...]", base class "PostgresCompiler" defined the type as "tuple[type[RowID], type[TimeDelta], type[ArrayFlatten], type[Kurtosis]]") [assignment]
+ ibis/backends/sql/compilers/risingwave.py:30: error: Incompatible types in assignment (expression has type "tuple[type[Arbitrary], type[Mode], type[RandomScalar], type[RandomUUID], type[MultiQuantile], type[ApproxMultiQuantile], type[Sample], type[Kurtosis], *tuple[type[GeoSpatialUnOp] | type[GeoSpatialBinOp] | type[GeoUnaryUnion], ...]]", base class "PostgresCompiler" defined the type as "tuple[type[RowID], type[TimeDelta], type[ArrayFlatten], type[Kurtosis]]") [assignment]
- ibis/expr/operations/tests/test_generic.py:111: error: Too many arguments for "Literal" [call-arg]
+ ibis/expr/operations/tests/test_generic.py:111: error: Too many positional arguments for "Literal" [call-arg]
- ibis/common/tests/test_grounds.py:777: error: Too many arguments for "StringOp" [call-arg]
+ ibis/common/tests/test_grounds.py:777: error: Too many positional arguments for "StringOp" [call-arg]
- ibis/common/tests/test_grounds.py:989: error: Too many arguments for "AnnSing" [call-arg]
+ ibis/common/tests/test_grounds.py:989: error: Too many positional arguments for "AnnSing" [call-arg]
- ibis/common/tests/test_grounds.py:990: error: Too many arguments for "AnnSing" [call-arg]
+ ibis/common/tests/test_grounds.py:990: error: Too many positional arguments for "AnnSing" [call-arg]
- ibis/common/tests/test_grounds.py:991: error: Too many arguments for "AnnSing" [call-arg]
+ ibis/common/tests/test_grounds.py:991: error: Too many positional arguments for "AnnSing" [call-arg]
- ibis/common/tests/test_grounds.py:992: error: Too many arguments for "AnnSing" [call-arg]
+ ibis/common/tests/test_grounds.py:992: error: Too many positional arguments for "AnnSing" [call-arg]
- ibis/common/tests/test_grounds.py:995: error: Too many arguments for "SingAnn" [call-arg]
+ ibis/common/tests/test_grounds.py:995: error: Too many positional arguments for "SingAnn" [call-arg]
- ibis/common/tests/test_grounds.py:996: error: Too many arguments for "SingAnn" [call-arg]
+ ibis/common/tests/test_grounds.py:996: error: Too many positional arguments for "SingAnn" [call-arg]
- ibis/common/tests/test_grounds.py:997: error: Too many arguments for "SingAnn" [call-arg]
+ ibis/common/tests/test_grounds.py:997: error: Too many positional arguments for "SingAnn" [call-arg]
- ibis/common/tests/test_grounds.py:999: error: Too many arguments for "SingAnn" [call-arg]
+ ibis/common/tests/test_grounds.py:999: error: Too many positional arguments for "SingAnn" [call-arg]
discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/core.py:1075: error: Unused "type: ignore" comment [unused-ignore]
- discord/ext/commands/core.py:1708: error: Unused "type: ignore" comment [unused-ignore]
- discord/ext/tasks/__init__.py:500: error: Incompatible types in assignment (expression has type "tuple[type, ...]", variable has type "tuple[type[OSError], type[GatewayNotFound], type[ConnectionClosed], type[ClientError], type[TimeoutError]]") [assignment]
+ discord/ext/tasks/__init__.py:500: error: Incompatible types in assignment (expression has type "tuple[type[OSError], type[GatewayNotFound], type[ConnectionClosed], type[ClientError], type[TimeoutError], *tuple[type[BaseException], ...]]", variable has type "tuple[type[OSError], type[GatewayNotFound], type[ConnectionClosed], type[ClientError], type[TimeoutError]]") [assignment]
dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ ddtrace/llmobs/_experiment.py:490: error: Argument 1 to "set_exc_info" of "Span" has incompatible type "*tuple[type[BaseException], BaseException, TracebackType] | tuple[None, None, None]"; expected "type[BaseException]" [arg-type]
+ ddtrace/llmobs/_experiment.py:490: error: Argument 1 to "set_exc_info" of "Span" has incompatible type "*tuple[type[BaseException], BaseException, TracebackType] | tuple[None, None, None]"; expected "BaseException" [arg-type]
+ ddtrace/llmobs/_integrations/bedrock_agents.py:244: error: Argument 1 to "set_exc_info" of "Span" has incompatible type "*tuple[type[BaseException], BaseException, TracebackType] | tuple[None, None, None]"; expected "type[BaseException]" [arg-type]
+ ddtrace/llmobs/_integrations/bedrock_agents.py:244: error: Argument 1 to "set_exc_info" of "Span" has incompatible type "*tuple[type[BaseException], BaseException, TracebackType] | tuple[None, None, None]"; expected "BaseException" [arg-type]
+ ddtrace/llmobs/_integrations/bedrock_agents.py:293: error: Argument 1 to "set_exc_info" of "Span" has incompatible type "*tuple[type[BaseException], BaseException, TracebackType] | tuple[None, None, None]"; expected "type[BaseException]" [arg-type]
+ ddtrace/llmobs/_integrations/bedrock_agents.py:293: error: Argument 1 to "set_exc_info" of "Span" has incompatible type "*tuple[type[BaseException], BaseException, TracebackType] | tuple[None, None, None]"; expected "BaseException" [arg-type]
jax (https://github.com/google/jax)
+ jaxlib/gpu_linalg.py:31: error: Generator has incompatible item type "tuple[*tuple[Any, ...], int]"; expected "tuple[str, Any, int]" [misc]
+ jaxlib/gpu_solver.py:40: error: Generator has incompatible item type "tuple[*tuple[Any, ...], int]"; expected "tuple[str, Any, int]" [misc]
+ jax/_src/interpreters/ad.py:60: error: Argument 2 to "annotate" has incompatible type "tuple[AbstractValue | Any, ...]"; expected "tuple[AbstractValue] | None" [arg-type]
+ jax/_src/interpreters/pxla.py:2104: error: Incompatible return value type (got "tuple[Layout | None, ...]", expected "tuple[Layout | None]") [return-value]
+ jax/_src/state/primitives.py:827: error: Incompatible types in assignment (expression has type "tuple[()]", variable has type "tuple[int, *tuple[int | Array, ...]]") [assignment]
+ jax/_src/lax/parallel.py:821: error: Incompatible return value type (got "tuple[str, ...]", expected "tuple[str]") [return-value]
+ jax/experimental/mosaic/gpu/utils.py:1991: error: Incompatible return value type (got "tuple[*tuple[Any, ...], Any]", expected "tuple[Any, Any, Any, Any]") [return-value]
+ jax/experimental/mosaic/gpu/fragmented_array.py:238: error: Unused "type: ignore" comment [unused-ignore]
+ jax/experimental/mosaic/gpu/fragmented_array.py:238: error: Incompatible types in assignment (expression has type "tuple[tuple[int, ...] | list[int], ...]", variable has type "tuple[tuple[int, ...], ...]") [assignment]
+ jax/experimental/mosaic/gpu/fragmented_array.py:238: note: Error code "assignment" not covered by "type: ignore" comment
+ jax/experimental/mosaic/gpu/fragmented_array.py:239: error: Unused "type: ignore" comment [unused-ignore]
+ jax/experimental/mosaic/gpu/fragmented_array.py:239: error: Incompatible types in assignment (expression has type "tuple[tuple[int, ...] | list[int], ...]", variable has type "tuple[tuple[int, ...], ...]") [assignment]
+ jax/experimental/mosaic/gpu/fragmented_array.py:239: note: Error code "assignment" not covered by "type: ignore" comment
trio (https://github.com/python-trio/trio)
+ src/trio/_core/_run.py:1972: error: Unused "type: ignore" comment [unused-ignore]
pyodide (https://github.com/pyodide/pyodide)
+ pyodide-build/pyodide_build/xbuildenv.py:309: error: List item 0 has incompatible type "list[str | None] | list[str]"; expected "str | bytes | PathLike[str] | PathLike[bytes]" [list-item]
pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ tests/test_string_accessors.py:172: error: Unused "type: ignore" comment [unused-ignore]
+ tests/test_string_accessors.py:172: error: Too many positional arguments for "wrap" of "StringMethods" [call-arg]
+ tests/test_string_accessors.py:172: note: Error code "call-arg" not covered by "type: ignore" comment
+ tests/test_string_accessors.py:230: error: Unused "type: ignore" comment [unused-ignore]
+ tests/test_string_accessors.py:230: error: Too many positional arguments for "wrap" of "StringMethods" [call-arg]
+ tests/test_string_accessors.py:230: note: Error code "call-arg" not covered by "type: ignore" comment
scikit-learn (https://github.com/scikit-learn/scikit-learn)
+ sklearn/ensemble/_hist_gradient_boosting/tests/test_gradient_boosting.py:184: error: List item 0 has incompatible type "tuple[type[HistGradientBoostingClassifier], *tuple[Any, ...]]"; expected "tuple[type[BaseHistGradientBoosting], *tuple[Any, ...]]" [list-item]
+ sklearn/ensemble/_hist_gradient_boosting/tests/test_gradient_boosting.py:185: error: List item 1 has incompatible type "tuple[type[HistGradientBoostingClassifier], *tuple[Any, ...]]"; expected "tuple[type[BaseHistGradientBoosting], *tuple[Any, ...]]" [list-item]
apprise (https://github.com/caronc/apprise)
+ apprise/persistent_store.py:150: error: Too many positional arguments [call-arg]
- apprise/persistent_store.py:150: error: Function gets multiple values for keyword argument "usedforsecurity" [misc]
- apprise/persistent_store.py:151: error: Argument 1 has incompatible type "bytes"; expected "bool" [arg-type]
dedupe (https://github.com/dedupeio/dedupe)
+ dedupe/core.py:196: error: Argument 1 to "zip" has incompatible type "*tuple[int, Mapping[str, Any]] | tuple[str, Mapping[str, Any]]"; expected "Iterable[str]" [arg-type]
materialize (https://github.com/MaterializeInc/materialize)
- misc/python/materialize/output_consistency/ignore_filter/ignore_verdict.py:22: error: Too many arguments for "__init__" of "object" [call-arg]
+ misc/python/materialize/output_consistency/ignore_filter/ignore_verdict.py:22: error: Too many positional arguments for "__init__" of "object" [call-arg]
+ misc/python/materialize/mzcompose/composition.py:374: error: Argument 1 to "Popen" has incompatible type "list[object]"; expected "str | bytes | PathLike[str] | PathLike[bytes] | Sequence[str | bytes | PathLike[str] | PathLike[bytes]]" [arg-type]
+ misc/python/materialize/mzcompose/composition.py:460: error: Not all union combinations were tried because there are too many unions [misc]
+ misc/python/materialize/mzcompose/composition.py:461: error: Argument 1 to "run" has incompatible type "list[object]"; expected "str | bytes | PathLike[str] | PathLike[bytes] | Sequence[str | bytes | PathLike[str] | PathLike[bytes]]" [arg-type]
rotki (https://github.com/rotki/rotki)
+ rotkehlchen/globaldb/upgrades/v2_v3.py:212: error: Tuple index out of range [misc]
+ rotkehlchen/globaldb/upgrades/v2_v3.py:212: note: Variadic tuple can have length 1
+ rotkehlchen/globaldb/upgrades/v2_v3.py:213: error: Tuple index out of range [misc]
+ rotkehlchen/globaldb/upgrades/v2_v3.py:213: note: Variadic tuple can have length 1
+ rotkehlchen/globaldb/upgrades/v2_v3.py:214: error: Tuple index out of range [misc]
+ rotkehlchen/globaldb/upgrades/v2_v3.py:214: note: Variadic tuple can have length 1
+ rotkehlchen/globaldb/upgrades/v2_v3.py:216: error: Tuple index out of range [misc]
+ rotkehlchen/globaldb/upgrades/v2_v3.py:216: note: Variadic tuple can have length 1
+ rotkehlchen/globaldb/upgrades/v2_v3.py:218: error: Tuple index out of range [misc]
+ rotkehlchen/globaldb/upgrades/v2_v3.py:218: note: Variadic tuple can have length 1
+ rotkehlchen/globaldb/upgrades/v2_v3.py:219: error: Tuple index out of range [misc]
+ rotkehlchen/globaldb/upgrades/v2_v3.py:219: note: Variadic tuple can have length 1
+ rotkehlchen/globaldb/upgrades/v2_v3.py:223: error: Tuple index out of range [misc]
+ rotkehlchen/globaldb/upgrades/v2_v3.py:223: note: Variadic tuple can have length 1
+ rotkehlchen/globaldb/upgrades/v2_v3.py:228: error: Tuple index out of range [misc]
+ rotkehlchen/globaldb/upgrades/v2_v3.py:228: note: Variadic tuple can have length 1
+ rotkehlchen/globaldb/upgrades/v2_v3.py:229: error: Tuple index out of range [misc]
+ rotkehlchen/globaldb/upgrades/v2_v3.py:229: note: Variadic tuple can have length 1
+ rotkehlchen/globaldb/upgrades/v2_v3.py:230: error: Tuple index out of range [misc]
+ rotkehlchen/globaldb/upgrades/v2_v3.py:230: note: Variadic tuple can have length 1
+ rotkehlchen/globaldb/upgrades/v2_v3.py:232: error: Tuple index out of range [misc]
+ rotkehlchen/globaldb/upgrades/v2_v3.py:232: note: Variadic tuple can have length 1
+ rotkehlchen/chain/solana/decoding/decoder.py:583: error: Argument 6 to "decode_safely" has incompatible type "*tuple[SolanaEventDecoderContext | SolanaDecoderContext, *tuple[Any, ...]]"; expected "tuple[Any]" [arg-type]
+ rotkehlchen/chain/evm/decoding/decoder.py:466: error: Argument 6 to "decode_safely" has incompatible type "*tuple[DecoderContext, *tuple[Any, ...]]"; expected "tuple[Any]" [arg-type]
static-frame (https://github.com/static-frame/static-frame)
+ static_frame/test/typing/test_frame.py:308: error: Incompatible types in assignment (expression has type "Frame[IndexDate, Index[str_], *tuple[Any, ...]]", variable has type "Frame[IndexDate, Index[str_]]") [assignment]
xarray (https://github.com/pydata/xarray)
+ xarray/core/datatree.py: note: In function "pipe":
+ xarray/core/datatree.py:1896: error: Argument 2 has incompatible type "*tuple[Any, ...]"; expected "P.args" [arg-type]
+ xarray/tests/test_deprecation_helpers.py:18: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_function":
+ xarray/tests/test_deprecation_helpers.py:18: error: Too many positional arguments for "f1" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:18: note: Error code "call-arg" not covered by "type: ignore" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:22: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_function":
+ xarray/tests/test_deprecation_helpers.py:22: error: Too many positional arguments for "f1" [call-arg]
+ xarray/tests/test_deprecation_helpers.py:22: note: Error code "call-arg" not covered by "type: ignore" comment
+ xarray/tests/test_deprecation_helpers.py: note: At top level:
+ xarray/tests/test_deprecation_helpers.py:26: error: Unused "type: ignore" comment [unused-ignore]
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_function":
+ xarray/tests/test_deprecation_helpers.py:26: error: Too many positional arguments for "f1" [call-arg]
... (truncated 76 lines) ...``` |
Open Problems
|
Apologies in advance for this monster PR.
This is based on #19651, which had a flaw discovered in #19651 (comment), that turned out to be lethal for the approach taken. It turns out we need much more machinery and rework a few major pieces to get everything working.
Fixed issues
mypydoesn't understand that*args: P.argsimplies thatargsis atuple#19663mypyfails to correctly understand some iterable type in*args#19662tuple[int, *Ts, int]as anIterable[T]. #19659Any#18320*argswhereargs: Union[Tuple[...], Tuple[...], ...]are _never_ checked [False Negative] #17161__iter__method yields false positive when used with star args (*) #14470Partially Fixed Issues
tuple[str, ...], see open problems below)__iter__with more specific item type is only respected in some contexts #16492 (unexpectedAnygone)What does this PR do?
Closes over 10 issues related to
*argsusage, by improving parsing of positional and star arguments, as well as tuple expressions. Highlights:some examples
This is a new unit test:
whereas on master, the output is just
https://mypy-play.net/?mypy=latest&python=3.12&gist=82739825de042dfeea487d83823d11bd
An extreme example
Below we have function that expectes 2 prefix items, a variadic type and 2 suffix items, as well as all 45 possible ways of bracketing these arguments as intermediate tuples (with at least 2 members).
On master, only 4 out of these 45 runtime legal calls succeed!!
Whereas with this PR, all 45 work. Code sample in pyright playground, https://mypy-play.net/?mypy=latest&python=3.12&gist=2be305f25ddbea0fc37f02b319a2d90d
Why the earlier PR failed
Correctly parsing unions of tuples requires all pieces of the machinery to work together, starting with
argmap.map_actuals_to_formals. A major obstacle is that the prior approach needed access to theTypeInfooftyping.Iterable,builtins.tupleandbuiltins.functionin order to parse are star argument. This information was provided byinfer.ArgumentInferContext. However, this information is not present in many places whereargmap.map_actuals_to_formalsis used (maybe this can be changed?)High Level Overview
To address the limitation, I added a piece of machinery I call
TupleNormalForm(TNF), which can be used to determine the prefix-size, suffix-size and whether a star argument will be variadic or not without actually materializing the tuple type. This step is delayed until theArgumentInferContextinformation is present.Details
This is accomplished by creating an abstract representation as a list of prefix types, list of suffix types and a "dirty" `UnpackType`, which can contain, appart from the usual stuff:UninhabitedTypeto indicate empty variadic partTypeListto indicate a concatenationUnionTypeto indicate union of multiple variadic items.For example, given a union of tuples,
tuple[int, int, int] | tuple[str, *tuple[str, ...], str], the TNF will result in:prefix = [int | str]unpack = *( *[int] | *tuple[str, ...] )or, spelled out:
UnpackType[UnionType[UnpackType[TypeList[int]], UnpackType[TupleInstance]]]suffix = [int | str]Moreover, the following pieces have been majorly refactored:
argmap.ArgTypeExpanderparse_star_argument: new method that converts*argsargument into aTupleTypeparse_star_parameter: new method that converts*args : Tparameter into aTupleTypeunparse_star_parameter: new method that reverts certain normalization done by the previous methodexpand_actual_type: complete rewrite of theARG_STARbranch.Now,
*argsargument will in a first step always be parsed into aTupleType. Then, ifformal_kindisARG_POSwe return a single item from the tuple, and if it isARG_STAR, we return a slice from the tuple.infer.ArgumentInferContextbuiltins.functionandbuiltins.tupletype.checkexpr.Expressionchecker:check_argument_count: refactored. Mostly cleanup, but added new check for too few arguments forARG_STAR, by inspecting the TNF.check_for_extra_actual_arguments: refactored, two big changes: (1) we now use TNF to check for too many positional arguments. Previously, this just checked.itemswhenactual_typewas aTupleType, which does not work e.g. for unions of tuples. (2) now issuestoo_many_positional_argumentswhen unallocatedARG_POS/ARG_STARis detected, hence a lot of tests changed fromtoo many argumentstotoo many positional arguments.check_argument_types: rewritten from scratch, and majorly simplified.too_many_argumentsandtoo_few_argumentschecks, this is now completely handled by the reworkedcheck_argument_countmethod.ARG_STARis straightforwardARG_STARnow works by first converting the formal type to a tuple, and then, for each actual mapped to it, creating anexpected_typewhich is either an item of that tuple (if the actual isARG_POS) or a slice of that tuple (if the actual isARG_STAR).map_actuals_to_star_parametervisit_tuple_expression: makes use of the TNF machinery to give more precise results (even more precise thanallow_precise_tuples)Example
Consider unit test
testPackingVariadicTuplesTypeVar: mypy-playCurrently,
(*arg, *arg)becomestuple[object, ...]whenarg=tuple[int, *Ts, str]. With the rework, it becomes the much more precisetuple[int, *tuple[int | str | Any, ...], str].Generally, the machinery maintains prefixes and suffixes. Maybe in the future one could maintain the minimum length as well, or even allow multiple unpacks.
constraints.infer_constraints_for_callable: major reworkArgTypeExpanderto all actuals.formal_kind.formal_kind == ARG_STARwe create a singleTupleTypefrom all the actuals mapping onto the formal type and compare them as tuples.Constraints.ConstraintBuilderVisitorvisit_type_var_tuple: added some rudimentary casesvisit_instance: ensured that flattened tuple items are used inside when both are tuple-like.visit_tuple_type: rewritten from scratchWhen comparing two tuples, we now consider the TNF of both
actualandtemplate, and branch into 4 possible cases, depending on whether either of them is variadic. We greedily match prefix and suffix items and match the remaining sub-tuples appropriately.subtypes.variadic_tuple_subtype: this is probably the most controversial, and may require some more work.After some discussion here Incorrect mapping of actual to formal arguments. #19692 (comment), the idea was to allow variadic tuples to match any requested size. (e.g.
*argof typetuple[str, *tuple[str, ...]]is valid for a function that needs exactly 2 strings.) That is, as an argument,tuple[str, ...]behaves likeAnyOfrather thanUnion(see AnyOf - Union for return types typing#566). I realized this by modifying subtyping behavior so that this is true, unless we checkis_proper_subtype. However, this introduces some side effects that are probably unwanted; consider the changes tocheck-typevar-tuple.test::testVariadicTupleSubtypingas an example.And some minor changes:
types.TupleType@cached_propertybut it is not possible due to__slots__.simplifymethod that reducestuple[*tuple[T, ...]]->tuple[T, ...]and similar.checker.TypeChecker.check_multi_assignment_from_tupleadded an extra branch to deal with an issue detailed in Inconsistent constraint resolution for tuples. #19860 (comment)Open Problems
tuple(...)and tuple literals produce different inference:Custom iterators which overwrite
__iter__still produce too wide types(Overridden__iter__with more specific item type is only respected in some contexts #16492)The additional machinery in the current PR (TupleNormalForm) is quite complex, but could be severly simplified if the
TypeInfoofbuiltins.tupleandtyping.Iterablewere available globally.I haven't run any benchmark yet, but I could image the parsing is slower than before.
The more precise tuple handling introduced by this PR can introduce intermediary tuple types like
tuple[T, *tuple[S, ...]]which can trigger tuple index checks thatmypyomits fortuple[T, ...]. (see: tuple index out of range error is inconsistent #20475,tuple[Any, *tuple[Any, ...]]is not assignable to other tuple types #19109 and Lenient TypeVarTuple checking when number of dimensions is unknown #18665 andmypy-primerresult forrotki)Changes to tests
tupleis present and a subtype of theIterable[T]Protocol.check_argument_countmany error cases have changed fromToo many argumentsto the more preciseToo many positional arguments.New Tests
testOverloadWithOverlappingItemsAndAnyArgument17(Inconsistent constraint resolution for tuples. #19860)testOverloadWithOverlappingItemsAndAnyArgument18(Inconsistent constraint resolution for tuples. #19860)testParamSpecArgsAsTupleInteraction(mypydoesn't understand that*args: P.argsimplies thatargsis atuple#19663)testLeftAndRightVariadicCoupledandtestLeftAndRightVariadicTypeVarTuple(Incorrect mapping of actual to formal arguments. #19692)testParamSpecWithVarArgsTypeVarTuple(Bad interaction between ParamSpec and TypeVarTuple #19855)testVarArgsEquivalentTuples(Incorrect mapping of actual to formal arguments. #19692, Inconsistent constraint resolution for tuples. #19860)testVarArgsVariableTuple(Incorrect mapping of actual to formal arguments. #19692)testTupleConversionWithUnionStarArgs: testsdef as_tuple[*Ts](*args: *Ts]) -> tuple[*Ts]with union argumentstestTupleExpressionWithUnionStarArgs,testListExpressionWithUnionStarArgs,testSetExpressionWithUnionStarArgs: test(*args),[*args]and{*args}whenargsis a uniontestStarArgsWithPaddedTupleArgumentUpcasttest passing union of padded variadic tuplestestStarArgsVariableTupleAssignable(Incorrect mapping of actual to formal arguments. #19692)`testStarArgsTupleExpressionVersusTypeVarTuplecomparesdef as_tuple[*Ts](*args: *Ts]) -> tuple[*Ts]against plain tuple expressiontestStarArgsWithUnionmore tests with*argsunion typetestStarArgsWithUnionSameTupleLengthsspecific test when union members are equal length tuplestestStarArgsWithUnionSameTupleLengthsOverloadtests an overloaded function when*argsis a unio with equal length tuplestestStarArgsWithUnionDifferentTupleLengthstests*argswith union of non-equal length tuplestestListExpressionWithListSubtypeStarArgs(mypyfails to correctly understand some iterable type in*args#19662)testStarArgsWithConcatenateParamSpectests*argswith tuple that contains*P.argstestStarArgsWithSuffixtests that different ways of passing the same argument give the same result when the function expects variadic tuple with suffix.testStarArgsWithPrefixAndSuffixTests all 45 possible ways of bracketing 2 positional prefix, one variadic star argument and 2 positional suffix argument.testVarArgsNumber(Incorrect mapping of actual to formal arguments. #19692) (TODO: duplicate test, remove)ConstraintsSuite.test_wrapped_tuple_identical_results(Inconsistent constraint resolution for tuples. #19860)