Fix invalid contextual inference for generic call arguments - #21803
Open
rheard wants to merge 1 commit into
Open
Fix invalid contextual inference for generic call arguments#21803rheard wants to merge 1 commit into
rheard wants to merge 1 commit into
Conversation
This comment has been minimized.
This comment has been minimized.
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: kornia (https://github.com/kornia/kornia)
+ kornia/models/efficient_vit/nn/act.py:36: error: Unused "type: ignore" comment [unused-ignore]
spark (https://github.com/apache/spark)
+ python/pyspark/ml/util.py:1168: error: Unused "type: ignore" comment [unused-ignore]
+ python/pyspark/ml/classification.py:3988: error: Unused "type: ignore" comment [unused-ignore]
prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/utilities/callables/__init__.py:717: error: Incompatible types in assignment (expression has type "list[None]", variable has type "list[expr | None]") [assignment]
- src/prefect/utilities/callables/__init__.py:717: note: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
- src/prefect/utilities/callables/__init__.py:717: note: Consider using "Sequence" instead, which is covariant
- src/prefect/utilities/callables/__init__.py:719: error: Unsupported operand types for + ("list[None]" and "list[expr | None]") [operator]
+ src/prefect/server/events/jinja_filters.py:86: error: Unused "type: ignore" comment [unused-ignore]
- src/prefect/task_runners.py:425: error: Argument 1 to "submit" of "Executor" has incompatible type "Callable[[Callable[_P, _T], **_P], _T]"; expected "def (Callable[[Task[P, R], UUID | None, TaskRun | None, dict[str, Any] | None, PrefectFuture[Any] | Any | Iterable[PrefectFuture[Any] | Any] | None, Literal['state', 'result'], dict[str, set[RunInput]] | None, dict[str, Any] | None], R | State[Any] | None], /, **Any) -> Any | State[Any] | None" [arg-type]
+ src/prefect/task_runners.py:425: error: Argument 1 to "submit" of "Executor" has incompatible type "Callable[[Callable[_P, _T], **_P], _T]"; expected "def [P] (Callable[[Task[P, R], UUID | None, TaskRun | None, dict[str, Any] | None, PrefectFuture[Any] | Any | Iterable[PrefectFuture[Any] | Any] | None, Literal['state', 'result'], dict[str, set[RunInput]] | None, dict[str, Any] | None], R | State[Any] | None], /, **Any) -> Any | State[Any] | None" [arg-type]
- src/prefect/flow_engine.py:2299: error: Unsupported operand types for | ("dict[str, str]" and "dict[str, str | None]") [operator]
colour (https://github.com/colour-science/colour)
- colour/io/luts/lut.py:1419: error: Argument 1 to "tile" has incompatible type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None"; expected "_SupportsArray[dtype[signedinteger[_8Bit] | signedinteger[_16Bit] | signedinteger[_32Bit] | signedinteger[_64Bit] | unsignedinteger[_8Bit] | unsignedinteger[_16Bit] | unsignedinteger[_32Bit] | unsignedinteger[_64Bit] | Any]] | _NestedSequence[_SupportsArray[dtype[signedinteger[_8Bit] | signedinteger[_16Bit] | signedinteger[_32Bit] | signedinteger[_64Bit] | unsignedinteger[_8Bit] | unsignedinteger[_16Bit] | unsignedinteger[_32Bit] | unsignedinteger[_64Bit] | Any]]]" [arg-type]
+ colour/io/luts/lut.py:1433: error: No overload variant of "pad" matches argument types "ndarray[Any, Any]", "tuple[int, Any | signedinteger[_8Bit] | signedinteger[_16Bit] | signedinteger[_32Bit] | signedinteger[_64Bit] | unsignedinteger[_8Bit] | unsignedinteger[_16Bit] | unsignedinteger[_32Bit] | unsignedinteger[_64Bit]]", "str", "float" [call-overload]
+ colour/io/luts/lut.py:1433: note: Possible overload variants:
+ colour/io/luts/lut.py:1433: note: def [ShapeT: tuple[int, ...], DTypeT: dtype[Any]] pad(array: ndarray[ShapeT, DTypeT], pad_width: _SupportsArray[dtype[integer[Any]]] | _NestedSequence[_SupportsArray[dtype[integer[Any]]]] | int | _NestedSequence[int] | dict[int, int] | dict[int, tuple[int, int]] | dict[int, int | tuple[int, int]], mode: Literal['constant', 'edge', 'linear_ramp', 'maximum', 'mean', 'median', 'minimum', 'reflect', 'symmetric', 'wrap', 'empty'] = ..., *, stat_length: _SupportsArray[dtype[integer[Any]]] | _NestedSequence[_SupportsArray[dtype[integer[Any]]]] | int | _NestedSequence[int] | None = ..., constant_values: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] = ..., end_values: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] = ..., reflect_type: Literal['odd', 'even'] = ...) -> ndarray[ShapeT, DTypeT]
+ colour/io/luts/lut.py:1433: note: def [ScalarT: generic[Any]] pad(array: _SupportsArray[dtype[ScalarT]] | _NestedSequence[_SupportsArray[dtype[ScalarT]]], pad_width: _SupportsArray[dtype[integer[Any]]] | _NestedSequence[_SupportsArray[dtype[integer[Any]]]] | int | _NestedSequence[int] | dict[int, int] | dict[int, tuple[int, int]] | dict[int, int | tuple[int, int]], mode: Literal['constant', 'edge', 'linear_ramp', 'maximum', 'mean', 'median', 'minimum', 'reflect', 'symmetric', 'wrap', 'empty'] = ..., *, stat_length: _SupportsArray[dtype[integer[Any]]] | _NestedSequence[_SupportsArray[dtype[integer[Any]]]] | int | _NestedSequence[int] | None = ..., constant_values: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] = ..., end_values: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] = ..., reflect_type: Literal['odd', 'even'] = ...) -> ndarray[tuple[Any, ...], dtype[ScalarT]]
+ colour/io/luts/lut.py:1433: note: def pad(array: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], pad_width: _SupportsArray[dtype[integer[Any]]] | _NestedSequence[_SupportsArray[dtype[integer[Any]]]] | int | _NestedSequence[int] | dict[int, int] | dict[int, tuple[int, int]] | dict[int, int | tuple[int, int]], mode: Literal['constant', 'edge', 'linear_ramp', 'maximum', 'mean', 'median', 'minimum', 'reflect', 'symmetric', 'wrap', 'empty'] = ..., *, stat_length: _SupportsArray[dtype[integer[Any]]] | _NestedSequence[_SupportsArray[dtype[integer[Any]]]] | int | _NestedSequence[int] | None = ..., constant_values: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] = ..., end_values: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] = ..., reflect_type: Literal['odd', 'even'] = ...) -> ndarray[tuple[Any, ...], dtype[Any]]
+ colour/io/luts/lut.py:1433: note: def [ShapeT: tuple[int, ...], DTypeT: dtype[Any]] pad(array: ndarray[ShapeT, DTypeT], pad_width: _SupportsArray[dtype[integer[Any]]] | _NestedSequence[_SupportsArray[dtype[integer[Any]]]] | int | _NestedSequence[int] | dict[int, int] | dict[int, tuple[int, int]] | dict[int, int | tuple[int, int]], mode: _ModeFunc, **kwargs: Any) -> ndarray[ShapeT, DTypeT]
+ colour/io/luts/lut.py:1433: note: def [ScalarT: generic[Any]] pad(array: _SupportsArray[dtype[ScalarT]] | _NestedSequence[_SupportsArray[dtype[ScalarT]]], pad_width: _SupportsArray[dtype[integer[Any]]] | _NestedSequence[_SupportsArray[dtype[integer[Any]]]] | int | _NestedSequence[int] | dict[int, int] | dict[int, tuple[int, int]] | dict[int, int | tuple[int, int]], mode: _ModeFunc, **kwargs: Any) -> ndarray[tuple[Any, ...], dtype[ScalarT]]
+ colour/io/luts/lut.py:1433: note: def pad(array: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], pad_width: _SupportsArray[dtype[integer[Any]]] | _NestedSequence[_SupportsArray[dtype[integer[Any]]]] | int | _NestedSequence[int] | dict[int, int] | dict[int, tuple[int, int]] | dict[int, int | tuple[int, int]], mode: _ModeFunc, **kwargs: Any) -> ndarray[tuple[Any, ...], dtype[Any]]
- colour/io/luts/lut.py:1955: error: Argument 1 to "tile" has incompatible type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None"; expected "_SupportsArray[dtype[signedinteger[_8Bit] | signedinteger[_16Bit] | signedinteger[_32Bit] | signedinteger[_64Bit] | unsignedinteger[_8Bit] | unsignedinteger[_16Bit] | unsignedinteger[_32Bit] | unsignedinteger[_64Bit]]] | _NestedSequence[_SupportsArray[dtype[signedinteger[_8Bit] | signedinteger[_16Bit] | signedinteger[_32Bit] | signedinteger[_64Bit] | unsignedinteger[_8Bit] | unsignedinteger[_16Bit] | unsignedinteger[_32Bit] | unsignedinteger[_64Bit]]]]" [arg-type]
+ colour/io/luts/lut.py:1955: error: Argument 1 to "tile" has incompatible type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None"; expected "_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]]" [arg-type]
artigraph (https://github.com/artigraph/artigraph)
+ src/arti/graphs/__init__.py:181: error: Unused "type: ignore" comment [unused-ignore]
pydantic (https://github.com/pydantic/pydantic)
- pydantic/main.py:126: error: Dict entry 1 has incompatible type "str": "Callable[[BaseModel, str, Any], dict[str, Any] | tuple[dict[str, Any], dict[str, Any] | None, set[str]] | Any]"; expected "str": "Callable[[BaseModel, str, Any], None]" [dict-item]
scipy (https://github.com/scipy/scipy)
- scipy/stats/tests/test_sampling.py:155: error: Unsupported operand types for + ("list[tuple[tuple[int, ...], type[ValueError], str] | tuple[tuple[int, int], type[UNURANError], str]]" and "list[tuple[tuple[float, float], type[ValueError], str]]") [operator]
rotki (https://github.com/rotki/rotki)
+ rotkehlchen/chain/evm/decoding/stakedao/decoder.py:315: error: Unused "type: ignore" comment [unused-ignore]
+ rotkehlchen/tasks/historical_balances.py:184: error: Incompatible return value type (got "list[tuple[Bucket, EventDirection]]", expected "list[tuple[Bucket, Literal[EventDirection.IN, EventDirection.OUT]]]") [return-value]
+ rotkehlchen/tasks/historical_balances.py:185: error: Unused "type: ignore" comment [unused-ignore]
- rotkehlchen/tests/api/test_calendar.py:156: error: Unsupported operand types for | ("dict[str, list[dict[str, str]]]" and "dict[str, int]") [operator]
- rotkehlchen/tests/api/test_calendar.py:168: error: Unsupported operand types for | ("dict[str, str]" and "dict[str, int]") [operator]
- rotkehlchen/tests/api/test_calendar.py:180: error: Unsupported operand types for | ("dict[str, str]" and "dict[str, int]") [operator]
- rotkehlchen/tests/api/test_calendar.py:192: error: Unsupported operand types for | ("dict[str, str]" and "dict[str, int]") [operator]
- rotkehlchen/tests/api/test_calendar.py:229: error: Unsupported operand types for | ("dict[str, list[dict[str, ChecksumAddress]]]" and "dict[str, int]") [operator]
sympy (https://github.com/sympy/sympy)
+ sympy/core/add.py:396: error: Unused "type: ignore" comment [unused-ignore]
+ sympy/polys/compatibility.py:402: error: Unused "type: ignore" comment [unused-ignore]
scikit-learn (https://github.com/scikit-learn/scikit-learn)
- sklearn/utils/tests/test_sparsefuncs.py:450: error: No overload variant of "hstack" matches argument types "list[Any]", "str" [call-overload]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: Possible overload variants:
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [T] hstack(blocks: Sequence[_CanStack[T]], format: None = ..., dtype: None = ...) -> T
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool]] hstack(blocks: Sequence[sparray[ScalarT, tuple[int, int]]], format: Literal['bsr'], dtype: None = ...) -> bsr_array[ScalarT]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool]] hstack(blocks: Sequence[sparray[ScalarT, tuple[int, int]]], format: Literal['coo'], dtype: None = ...) -> coo_array[ScalarT, tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool]] hstack(blocks: Sequence[sparray[ScalarT, tuple[int, int]]], format: Literal['csc'], dtype: None = ...) -> csc_array[ScalarT]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool]] hstack(blocks: Sequence[sparray[ScalarT, tuple[int, int]]], format: Literal['csr'], dtype: None = ...) -> csr_array[ScalarT, tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool]] hstack(blocks: Sequence[sparray[ScalarT, tuple[int, int]]], format: Literal['dia'], dtype: None = ...) -> dia_array[ScalarT]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool]] hstack(blocks: Sequence[sparray[ScalarT, tuple[int, int]]], format: Literal['dok'], dtype: None = ...) -> dok_array[ScalarT, tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool]] hstack(blocks: Sequence[sparray[ScalarT, tuple[int, int]]], format: Literal['lil'], dtype: None = ...) -> lil_array[ScalarT]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [T] hstack(blocks: Sequence[_CanStackAs[numpy.bool[builtins.bool], T]], format: None = ..., *, dtype: type[builtins.bool] | type[numpy.bool[builtins.bool]] | dtype[numpy.bool[builtins.bool]] | HasDType[dtype[numpy.bool[builtins.bool]]] | Literal['bool', 'bool_', 'b1', '|b1', '?']) -> T
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['bsr'], dtype: type[builtins.bool] | type[numpy.bool[builtins.bool]] | dtype[numpy.bool[builtins.bool]] | HasDType[dtype[numpy.bool[builtins.bool]]] | Literal['bool', 'bool_', 'b1', '|b1', '?']) -> bsr_array[numpy.bool[builtins.bool]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['coo'], dtype: type[builtins.bool] | type[numpy.bool[builtins.bool]] | dtype[numpy.bool[builtins.bool]] | HasDType[dtype[numpy.bool[builtins.bool]]] | Literal['bool', 'bool_', 'b1', '|b1', '?']) -> coo_array[numpy.bool[builtins.bool], tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['csc'], dtype: type[builtins.bool] | type[numpy.bool[builtins.bool]] | dtype[numpy.bool[builtins.bool]] | HasDType[dtype[numpy.bool[builtins.bool]]] | Literal['bool', 'bool_', 'b1', '|b1', '?']) -> csc_array[numpy.bool[builtins.bool]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['csr'], dtype: type[builtins.bool] | type[numpy.bool[builtins.bool]] | dtype[numpy.bool[builtins.bool]] | HasDType[dtype[numpy.bool[builtins.bool]]] | Literal['bool', 'bool_', 'b1', '|b1', '?']) -> csr_array[numpy.bool[builtins.bool], tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['dia'], dtype: type[builtins.bool] | type[numpy.bool[builtins.bool]] | dtype[numpy.bool[builtins.bool]] | HasDType[dtype[numpy.bool[builtins.bool]]] | Literal['bool', 'bool_', 'b1', '|b1', '?']) -> dia_array[numpy.bool[builtins.bool]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['dok'], dtype: type[builtins.bool] | type[numpy.bool[builtins.bool]] | dtype[numpy.bool[builtins.bool]] | HasDType[dtype[numpy.bool[builtins.bool]]] | Literal['bool', 'bool_', 'b1', '|b1', '?']) -> dok_array[numpy.bool[builtins.bool], tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['lil'], dtype: type[builtins.bool] | type[numpy.bool[builtins.bool]] | dtype[numpy.bool[builtins.bool]] | HasDType[dtype[numpy.bool[builtins.bool]]] | Literal['bool', 'bool_', 'b1', '|b1', '?']) -> lil_array[numpy.bool[builtins.bool]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [T] hstack(blocks: Sequence[_CanStackAs[signedinteger[_32Bit | _64Bit], T]], format: None = ..., *, dtype: type[JustInt] | type[signedinteger[_64Bit]] | dtype[signedinteger[_64Bit]] | HasDType[dtype[signedinteger[_64Bit]]] | Literal['int_', 'int', 'intp', 'n', '<n', '>n']) -> T
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['bsr'], dtype: type[JustInt] | type[signedinteger[_64Bit]] | dtype[signedinteger[_64Bit]] | HasDType[dtype[signedinteger[_64Bit]]] | Literal['int_', 'int', 'intp', 'n', '<n', '>n']) -> bsr_array[signedinteger[_32Bit | _64Bit]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['coo'], dtype: type[JustInt] | type[signedinteger[_64Bit]] | dtype[signedinteger[_64Bit]] | HasDType[dtype[signedinteger[_64Bit]]] | Literal['int_', 'int', 'intp', 'n', '<n', '>n']) -> coo_array[signedinteger[_32Bit | _64Bit], tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['csc'], dtype: type[JustInt] | type[signedinteger[_64Bit]] | dtype[signedinteger[_64Bit]] | HasDType[dtype[signedinteger[_64Bit]]] | Literal['int_', 'int', 'intp', 'n', '<n', '>n']) -> csc_array[signedinteger[_32Bit | _64Bit]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['csr'], dtype: type[JustInt] | type[signedinteger[_64Bit]] | dtype[signedinteger[_64Bit]] | HasDType[dtype[signedinteger[_64Bit]]] | Literal['int_', 'int', 'intp', 'n', '<n', '>n']) -> csr_array[signedinteger[_32Bit | _64Bit], tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['dia'], dtype: type[JustInt] | type[signedinteger[_64Bit]] | dtype[signedinteger[_64Bit]] | HasDType[dtype[signedinteger[_64Bit]]] | Literal['int_', 'int', 'intp', 'n', '<n', '>n']) -> dia_array[signedinteger[_32Bit | _64Bit]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['dok'], dtype: type[JustInt] | type[signedinteger[_64Bit]] | dtype[signedinteger[_64Bit]] | HasDType[dtype[signedinteger[_64Bit]]] | Literal['int_', 'int', 'intp', 'n', '<n', '>n']) -> dok_array[signedinteger[_32Bit | _64Bit], tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['lil'], dtype: type[JustInt] | type[signedinteger[_64Bit]] | dtype[signedinteger[_64Bit]] | HasDType[dtype[signedinteger[_64Bit]]] | Literal['int_', 'int', 'intp', 'n', '<n', '>n']) -> lil_array[signedinteger[_32Bit | _64Bit]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [T] hstack(blocks: Sequence[_CanStackAs[float64, T]], format: None = ..., *, dtype: type[JustFloat] | type[floating[_64Bit]] | dtype[floating[_64Bit]] | HasDType[dtype[floating[_64Bit]]] | Literal['float64', 'double', 'float', 'f8', '<f8', '>f8', 'd']) -> T
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['bsr'], dtype: type[JustFloat] | type[floating[_64Bit]] | dtype[floating[_64Bit]] | HasDType[dtype[floating[_64Bit]]] | Literal['float64', 'double', 'float', 'f8', '<f8', '>f8', 'd']) -> bsr_array[float64]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['coo'], dtype: type[JustFloat] | type[floating[_64Bit]] | dtype[floating[_64Bit]] | HasDType[dtype[floating[_64Bit]]] | Literal['float64', 'double', 'float', 'f8', '<f8', '>f8', 'd']) -> coo_array[float64, tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['csc'], dtype: type[JustFloat] | type[floating[_64Bit]] | dtype[floating[_64Bit]] | HasDType[dtype[floating[_64Bit]]] | Literal['float64', 'double', 'float', 'f8', '<f8', '>f8', 'd']) -> csc_array[float64]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['csr'], dtype: type[JustFloat] | type[floating[_64Bit]] | dtype[floating[_64Bit]] | HasDType[dtype[floating[_64Bit]]] | Literal['float64', 'double', 'float', 'f8', '<f8', '>f8', 'd']) -> csr_array[float64, tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['dia'], dtype: type[JustFloat] | type[floating[_64Bit]] | dtype[floating[_64Bit]] | HasDType[dtype[floating[_64Bit]]] | Literal['float64', 'double', 'float', 'f8', '<f8', '>f8', 'd']) -> dia_array[float64]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['dok'], dtype: type[JustFloat] | type[floating[_64Bit]] | dtype[floating[_64Bit]] | HasDType[dtype[floating[_64Bit]]] | Literal['float64', 'double', 'float', 'f8', '<f8', '>f8', 'd']) -> dok_array[float64, tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['lil'], dtype: type[JustFloat] | type[floating[_64Bit]] | dtype[floating[_64Bit]] | HasDType[dtype[floating[_64Bit]]] | Literal['float64', 'double', 'float', 'f8', '<f8', '>f8', 'd']) -> lil_array[float64]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [T] hstack(blocks: Sequence[_CanStackAs[complex128, T]], format: None = ..., *, dtype: type[JustComplex] | type[complexfloating[_64Bit, _64Bit]] | dtype[complexfloating[_64Bit, _64Bit]] | HasDType[dtype[complexfloating[_64Bit, _64Bit]]] | Literal['complex', 'complex128', 'cdouble', 'c16', '<c16', '>c16', 'D']) -> T
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['bsr'], dtype: type[JustComplex] | type[complexfloating[_64Bit, _64Bit]] | dtype[complexfloating[_64Bit, _64Bit]] | HasDType[dtype[complexfloating[_64Bit, _64Bit]]] | Literal['complex', 'complex128', 'cdouble', 'c16', '<c16', '>c16', 'D']) -> bsr_array[complex128]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['coo'], dtype: type[JustComplex] | type[complexfloating[_64Bit, _64Bit]] | dtype[complexfloating[_64Bit, _64Bit]] | HasDType[dtype[complexfloating[_64Bit, _64Bit]]] | Literal['complex', 'complex128', 'cdouble', 'c16', '<c16', '>c16', 'D']) -> coo_array[complex128, tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['csc'], dtype: type[JustComplex] | type[complexfloating[_64Bit, _64Bit]] | dtype[complexfloating[_64Bit, _64Bit]] | HasDType[dtype[complexfloating[_64Bit, _64Bit]]] | Literal['complex', 'complex128', 'cdouble', 'c16', '<c16', '>c16', 'D']) -> csc_array[complex128]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['csr'], dtype: type[JustComplex] | type[complexfloating[_64Bit, _64Bit]] | dtype[complexfloating[_64Bit, _64Bit]] | HasDType[dtype[complexfloating[_64Bit, _64Bit]]] | Literal['complex', 'complex128', 'cdouble', 'c16', '<c16', '>c16', 'D']) -> csr_array[complex128, tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['dia'], dtype: type[JustComplex] | type[complexfloating[_64Bit, _64Bit]] | dtype[complexfloating[_64Bit, _64Bit]] | HasDType[dtype[complexfloating[_64Bit, _64Bit]]] | Literal['complex', 'complex128', 'cdouble', 'c16', '<c16', '>c16', 'D']) -> dia_array[complex128]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['dok'], dtype: type[JustComplex] | type[complexfloating[_64Bit, _64Bit]] | dtype[complexfloating[_64Bit, _64Bit]] | HasDType[dtype[complexfloating[_64Bit, _64Bit]]] | Literal['complex', 'complex128', 'cdouble', 'c16', '<c16', '>c16', 'D']) -> dok_array[complex128, tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['lil'], dtype: type[JustComplex] | type[complexfloating[_64Bit, _64Bit]] | dtype[complexfloating[_64Bit, _64Bit]] | HasDType[dtype[complexfloating[_64Bit, _64Bit]]] | Literal['complex', 'complex128', 'cdouble', 'c16', '<c16', '>c16', 'D']) -> lil_array[complex128]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool], T] hstack(blocks: Sequence[_CanStackAs[ScalarT, T]], format: None = ..., *, dtype: type[ScalarT] | dtype[ScalarT] | HasDType[dtype[ScalarT]]) -> T
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool]] hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['bsr'], dtype: type[ScalarT] | dtype[ScalarT] | HasDType[dtype[ScalarT]]) -> bsr_array[ScalarT]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool]] hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['coo'], dtype: type[ScalarT] | dtype[ScalarT] | HasDType[dtype[ScalarT]]) -> coo_array[ScalarT, tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool]] hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['csc'], dtype: type[ScalarT] | dtype[ScalarT] | HasDType[dtype[ScalarT]]) -> csc_array[ScalarT]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool]] hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['csr'], dtype: type[ScalarT] | dtype[ScalarT] | HasDType[dtype[ScalarT]]) -> csr_array[ScalarT, tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool]] hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['dia'], dtype: type[ScalarT] | dtype[ScalarT] | HasDType[dtype[ScalarT]]) -> dia_array[ScalarT]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool]] hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['dok'], dtype: type[ScalarT] | dtype[ScalarT] | HasDType[dtype[ScalarT]]) -> dok_array[ScalarT, tuple[int, int]]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [ScalarT: number[Any, Any] | numpy.bool[builtins.bool]] hstack(blocks: Sequence[sparray[Any, tuple[Any, ...]]], format: Literal['lil'], dtype: type[ScalarT] | dtype[ScalarT] | HasDType[dtype[ScalarT]]) -> lil_array[ScalarT]
- sklearn/utils/tests/test_sparsefuncs.py:450: note: def [T] hstack(blocks: Sequence[_CanStackAs[Any, T]], format: None = ..., *, dtype: type[complex] | type[number[Any, Any]] | type[numpy.bool[builtins.bool]] | dtype[number[Any, Any] | numpy.bool[builtins.bool]] | str) -> T
... (truncated 9 lines) ...
schemathesis (https://github.com/schemathesis/schemathesis)
- src/schemathesis/generation/jsonschema/strategy.py:190: error: Argument 1 to "filter" of "SearchStrategy" has incompatible type "Callable[[Any, Any], bool]"; expected "Callable[[JsonValue], TypeGuard[Any]]" [arg-type]
- src/schemathesis/generation/jsonschema/strategy.py:1199: error: Argument 1 to "filter" of "SearchStrategy" has incompatible type "Callable[[Any], bool | Any]"; expected "Callable[[JsonValue], TypeGuard[dict[str, JsonValue] | list[JsonValue] | str | int | float | None]]" [arg-type]
+ src/schemathesis/generation/jsonschema/strategy.py:1199: error: Argument 1 to "filter" of "SearchStrategy" has incompatible type "Callable[[Any], bool | Any]"; expected "Callable[[JsonValue], TypeGuard[Never]]" [arg-type]
- src/schemathesis/specs/openapi/coverage/_schema.py:2811: error: Argument 1 to "filter" of "SearchStrategy" has incompatible type "Callable[[Any, Any], bool]"; expected "Callable[[str], TypeGuard[str]]" [arg-type]
+ src/schemathesis/specs/openapi/coverage/_schema.py:2811: error: Argument 1 to "filter" of "SearchStrategy" has incompatible type "Callable[[Any, Any], bool]"; expected "Callable[[str], TypeGuard[Never]]" [arg-type]
- src/schemathesis/specs/openapi/adapter/parameters.py:2168: error: Argument 1 to "filter" of "SearchStrategy" has incompatible type "Callable[[Any], bool]"; expected "Callable[[None], TypeGuard[None]]" [arg-type]
+ src/schemathesis/specs/openapi/adapter/parameters.py:2168: error: Argument 1 to "filter" of "SearchStrategy" has incompatible type "Callable[[Any], bool]"; expected "Callable[[None], TypeGuard[Never]]" [arg-type]
- src/schemathesis/specs/openapi/adapter/parameters.py:2189: error: Argument 1 to "filter" of "SearchStrategy" has incompatible type "Callable[[Any], bool]"; expected "Callable[[None], TypeGuard[None]]" [arg-type]
+ src/schemathesis/specs/openapi/adapter/parameters.py:2189: error: Argument 1 to "filter" of "SearchStrategy" has incompatible type "Callable[[Any], bool]"; expected "Callable[[None], TypeGuard[Never]]" [arg-type]
- src/schemathesis/specs/openapi/adapter/parameters.py:2217: error: Argument 1 to "filter" of "SearchStrategy" has incompatible type "Callable[[Any], bool]"; expected "Callable[[None], TypeGuard[None]]" [arg-type]
+ src/schemathesis/specs/openapi/adapter/parameters.py:2217: error: Argument 1 to "filter" of "SearchStrategy" has incompatible type "Callable[[Any], bool]"; expected "Callable[[None], TypeGuard[Never]]" [arg-type]
pandas (https://github.com/pandas-dev/pandas)
+ pandas/tests/dtypes/test_missing.py:862: error: Unused "type: ignore" comment [unused-ignore]
+ pandas/tests/dtypes/test_missing.py:884: error: Unused "type: ignore" comment [unused-ignore]
+ pandas/conftest.py:1759: error: Unused "type: ignore" comment [unused-ignore]
xarray (https://github.com/pydata/xarray)
+ xarray/tests/test_dataarray.py:424: error: Unused "type: ignore" comment [unused-ignore]
ibis (https://github.com/ibis-project/ibis)
- ibis/expr/operations/udf.py:144: error: Dict entry 1 has incompatible type "str": "InputType"; expected "str": "Argument" [dict-item]
- ibis/expr/operations/udf.py:147: error: Dict entry 2 has incompatible type "str": "property"; expected "str": "Argument" [dict-item]
- ibis/expr/operations/udf.py:148: error: Dict entry 3 has incompatible type "str": "FrozenDict[Never, Never]"; expected "str": "Argument" [dict-item]
- ibis/expr/operations/udf.py:149: error: Dict entry 4 has incompatible type "str": "Namespace"; expected "str": "Argument" [dict-item]
- ibis/expr/operations/udf.py:150: error: Dict entry 5 has incompatible type "str": "str"; expected "str": "Argument" [dict-item]
- ibis/expr/operations/udf.py:151: error: Dict entry 6 has incompatible type "str": "str"; expected "str": "Argument" [dict-item]
alectryon (https://github.com/cpitclaudel/alectryon)
- alectryon/core.py:251: error: Argument 3 to "ungroup_by" has incompatible type "Callable[[T], K | None]"; expected "Callable[[T | U], K | None]" [arg-type]
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19304
Mypy can use the outer return context to specialize a generic callable before it has checked whether the actual arguments still fit the specialized signature.
This can produce false positives when the contextual type is wider than the actual argument supports. For example, in the issue repro the outer
Iterable[int | str]context pushesVec.__add__toward acceptingVec[int | str], but the actual argument isVec[int], andVecis invariant.This PR keeps the existing contextual inference path, but adds a guard before committing to the context-specialized callable. If the specialized argument types are not compatible with the actual arguments, mypy falls back to ordinary argument inference, but only when that ordinary inferred return type still satisfies the original outer context.
The fallback is intentionally narrow. Constructors and special synthetic signatures keep the old behavior, since broader fallback caused regressions in existing tests, including
testAbstractTypeInADictand constructor/type-alias cases that started reportingNever-based expected types.Regression tests cover:
Vec.__add__min(..., key=...)-style callback case where return context widens the item type too far