Skip to content

[ty] Relax union variadic guard to check only parameters beyond minimum length#23298

Merged
carljm merged 5 commits intomainfrom
charlie/iter-2
Mar 25, 2026
Merged

[ty] Relax union variadic guard to check only parameters beyond minimum length#23298
carljm merged 5 commits intomainfrom
charlie/iter-2

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

Summary

The guard condition for per-element union iteration in match_variadic previously required all remaining positional parameters to be defaulted. This was overly conservative. We only need parameters beyond the shortest union element's length to be defaulted, since those positions are guaranteed to be provided by every union element.

See: https://github.com/astral-sh/ruff/pull/23124/changes#r2806496807.

@charliermarsh charliermarsh added the ty Multi-file analysis & type inference label Feb 15, 2026
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Feb 15, 2026

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 86.46%. The percentage of expected errors that received a diagnostic held steady at 80.68%. The number of fully passing files held steady at 67/132.

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Feb 15, 2026

mypy_primer results

Changes were detected when running on open source projects
pip (https://github.com/pypa/pip)
- src/pip/_internal/req/req_uninstall.py:132:42: error[invalid-argument-type] Argument to function `norm_join` is incorrect: Expected `str`, found `Sized | Unknown`
+ src/pip/_internal/req/req_uninstall.py:132:42: error[invalid-argument-type] Argument to function `norm_join` is incorrect: Expected `str`, found `Unknown | Sized`
- src/pip/_internal/req/req_uninstall.py:133:40: error[invalid-argument-type] Argument to function `norm_join` is incorrect: Expected `str`, found `Sized | Unknown`
+ src/pip/_internal/req/req_uninstall.py:133:40: error[invalid-argument-type] Argument to function `norm_join` is incorrect: Expected `str`, found `Unknown | Sized`
- src/pip/_internal/req/req_uninstall.py:139:27: error[unsupported-operator] Operator `+` is not supported between objects of type `Sized | Unknown` and `LiteralString`
+ src/pip/_internal/req/req_uninstall.py:139:27: error[unsupported-operator] Operator `+` is not supported between objects of type `Unknown | Sized` and `LiteralString`

spack (https://github.com/spack/spack)
- lib/spack/spack/detection/path.py:169:33: error[invalid-argument-type] Argument to function `dedupe_paths` is incorrect: Expected `list[str]`, found `Unknown | list[int | str | bytes | ... omitted 3 union elements]`
+ lib/spack/spack/detection/path.py:169:33: error[invalid-argument-type] Argument to function `dedupe_paths` is incorrect: Expected `list[str]`, found `Unknown | list[int | bytes | PathLike[str] | ... omitted 3 union elements]`
- lib/spack/spack/verify_libraries.py:164:46: error[invalid-argument-type] Argument to function `candidate_matches` is incorrect: Expected `bytes`, found `Unknown | bytes | str | PathLike[str] | PathLike[bytes]`
+ lib/spack/spack/verify_libraries.py:164:46: error[invalid-argument-type] Argument to function `candidate_matches` is incorrect: Expected `bytes`, found `bytes | Unknown | str | PathLike[str] | PathLike[bytes]`
- lib/spack/spack/verify_libraries.py:165:17: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown | bytes | str | PathLike[str] | PathLike[bytes]` and value of type `Unknown | bytes | str | PathLike[str] | PathLike[bytes]` on object of type `dict[bytes, bytes]`
+ lib/spack/spack/verify_libraries.py:165:17: error[invalid-assignment] Invalid subscript assignment with key of type `bytes | Unknown | str | PathLike[str] | PathLike[bytes]` and value of type `bytes | Unknown | str | PathLike[str] | PathLike[bytes]` on object of type `dict[bytes, bytes]`
- lib/spack/spack/verify_libraries.py:170:57: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `list[bytes]`, found `list[Unknown | bytes | str | PathLike[str] | PathLike[bytes]]`
+ lib/spack/spack/verify_libraries.py:170:57: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `list[bytes]`, found `list[bytes | Unknown | str | PathLike[str] | PathLike[bytes]]`
- lib/spack/spack/verify_libraries.py:170:69: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `list[bytes]`, found `list[Unknown | bytes | str | PathLike[str] | PathLike[bytes]]`
+ lib/spack/spack/verify_libraries.py:170:69: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `list[bytes]`, found `list[bytes | Unknown | str | PathLike[str] | PathLike[bytes]]`

rich (https://github.com/Textualize/rich)
- tests/test_tools.py:17:17: error[invalid-argument-type] Argument to function `next` is incorrect: Expected `SupportsNext[Unknown]`, found `Iterable[tuple[bool, str | Unknown]]`
+ tests/test_tools.py:17:17: error[invalid-argument-type] Argument to function `next` is incorrect: Expected `SupportsNext[Unknown]`, found `Iterable[tuple[bool, Unknown | str]]`
- tests/test_tools.py:18:17: error[invalid-argument-type] Argument to function `next` is incorrect: Expected `SupportsNext[Unknown]`, found `Iterable[tuple[bool, str | Unknown]]`
+ tests/test_tools.py:18:17: error[invalid-argument-type] Argument to function `next` is incorrect: Expected `SupportsNext[Unknown]`, found `Iterable[tuple[bool, Unknown | str]]`
- tests/test_tools.py:19:17: error[invalid-argument-type] Argument to function `next` is incorrect: Expected `SupportsNext[Unknown]`, found `Iterable[tuple[bool, str | Unknown]]`
+ tests/test_tools.py:19:17: error[invalid-argument-type] Argument to function `next` is incorrect: Expected `SupportsNext[Unknown]`, found `Iterable[tuple[bool, Unknown | str]]`
- tests/test_tools.py:20:17: error[invalid-argument-type] Argument to function `next` is incorrect: Expected `SupportsNext[Unknown]`, found `Iterable[tuple[bool, str | Unknown]]`
+ tests/test_tools.py:20:17: error[invalid-argument-type] Argument to function `next` is incorrect: Expected `SupportsNext[Unknown]`, found `Iterable[tuple[bool, Unknown | str]]`

PyGithub (https://github.com/PyGithub/PyGithub)
- github/Requester.py:899:57: error[invalid-argument-type] Argument to bound method `__hostnameHasDomain` is incorrect: Expected `str | list[str]`, found `Unknown | list[Unknown | str] | list[None | Unknown | str]`
+ github/Requester.py:899:57: error[invalid-argument-type] Argument to bound method `__hostnameHasDomain` is incorrect: Expected `str | list[str]`, found `Unknown | list[Unknown | str] | list[str | Unknown | None]`

pylox (https://github.com/sco1/pylox)
- pylox/containers/array.py:146:9: error[invalid-assignment] Object of type `deque[Unknown | None]` is not assignable to attribute `fields` of type `dict[Unknown, Unknown]`
+ pylox/containers/array.py:146:9: error[invalid-assignment] Object of type `deque[None | Unknown]` is not assignable to attribute `fields` of type `dict[Unknown, Unknown]`

artigraph (https://github.com/artigraph/artigraph)
- tests/arti/types/test_types.py:100:51: error[invalid-argument-type] Argument is incorrect: Expected `frozenset[Any]`, found `frozenset[float | Unknown | int] | list[Unknown | int | float] | tuple[float | Unknown | int, ...]`
+ tests/arti/types/test_types.py:100:51: error[invalid-argument-type] Argument is incorrect: Expected `frozenset[Any]`, found `frozenset[float | Unknown | int] | list[int | Unknown | float] | tuple[float | Unknown | int, ...]`

Expression (https://github.com/cognitedata/Expression)
+ tests/test_compose.py:21:16: error[invalid-assignment] Object of type `(Never, /) -> Never` is not assignable to `(int, /) -> int`
- Found 204 diagnostics
+ Found 205 diagnostics

comtypes (https://github.com/enthought/comtypes)
+ comtypes/_memberspec.py:73:61: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 498 diagnostics
+ Found 499 diagnostics

meson (https://github.com/mesonbuild/meson)
- mesonbuild/dependencies/cuda.py:137:76: error[invalid-argument-type] Argument to function `version_compare_many` is incorrect: Expected `str`, found `Unknown | str | None`
+ mesonbuild/dependencies/cuda.py:137:76: error[invalid-argument-type] Argument to function `version_compare_many` is incorrect: Expected `str`, found `str | None | Unknown`

cloud-init (https://github.com/canonical/cloud-init)
- tests/unittests/distros/test_user_data_normalize.py:24:31: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[Unknown, Unknown]`, found `Unknown | bool | list[Unknown] | ... omitted 3 union elements`
+ tests/unittests/distros/test_user_data_normalize.py:24:31: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[Unknown, Unknown]`, found `Unknown | dict[Unknown | str, Unknown | str] | str | ... omitted 3 union elements`
- tests/unittests/sources/test_gce.py:71:31: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[Unknown, Unknown]`, found `Unknown | bool | list[Unknown] | ... omitted 3 union elements`
+ tests/unittests/sources/test_gce.py:71:31: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[Unknown, Unknown]`, found `Unknown | dict[Unknown | str, Unknown | str] | str | ... omitted 3 union elements`

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- tests/tracer/test_span.py:193:29: error[invalid-argument-type] Argument to bound method `set_metric` is incorrect: Expected `int | float`, found `Unknown | None | dict[Unknown, Unknown] | ... omitted 6 union elements`
+ tests/tracer/test_span.py:193:29: error[invalid-argument-type] Argument to bound method `set_metric` is incorrect: Expected `int | float`, found `str | Unknown | None | ... omitted 6 union elements`

ibis (https://github.com/ibis-project/ibis)
- ibis/selectors.py:333:16: error[invalid-return-type] Return type does not match returned value: expected `frozenset[str]`, found `frozenset[str | Buffer | Unknown]`
+ ibis/selectors.py:333:16: error[invalid-return-type] Return type does not match returned value: expected `frozenset[str]`, found `frozenset[Unknown | str | Buffer]`
- ibis/selectors.py:428:13: error[invalid-assignment] Object of type `frozenset[str | Unknown]` is not assignable to `tuple[str | Column, ...]`
+ ibis/selectors.py:428:13: error[invalid-assignment] Object of type `frozenset[Unknown | str]` is not assignable to `tuple[str | Column, ...]`

static-frame (https://github.com/static-frame/static-frame)
- static_frame/test/unit/test_frame_iter.py:1389:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `Any | tuple[Any, Any]`
+ static_frame/test/unit/test_frame_iter.py:1389:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `tuple[Any, Any] | Any`
- static_frame/test/unit/test_frame_iter.py:1397:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `Any | tuple[Any, Any]`
+ static_frame/test/unit/test_frame_iter.py:1397:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `tuple[Any, Any] | Any`
- static_frame/test/unit/test_frame_iter.py:1408:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `Any | tuple[Any, Any]`
+ static_frame/test/unit/test_frame_iter.py:1408:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `tuple[Any, Any] | Any`
- static_frame/test/unit/test_frame_iter.py:1411:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `Any | tuple[Any, Any]`
+ static_frame/test/unit/test_frame_iter.py:1411:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `tuple[Any, Any] | Any`
- static_frame/test/unit/test_frame_iter.py:1431:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `Any | tuple[Any, Any]`
+ static_frame/test/unit/test_frame_iter.py:1431:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `tuple[Any, Any] | Any`
- static_frame/test/unit/test_frame_iter.py:1439:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `Any | tuple[Any, Any]`
+ static_frame/test/unit/test_frame_iter.py:1439:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `tuple[Any, Any] | Any`
- static_frame/test/unit/test_frame_iter.py:1481:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `Any | tuple[Any, Any]`
+ static_frame/test/unit/test_frame_iter.py:1481:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `tuple[Any, Any] | Any`
- static_frame/test/unit/test_frame_iter.py:1489:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `Any | tuple[Any, Any]`
+ static_frame/test/unit/test_frame_iter.py:1489:13: error[unresolved-attribute] Attribute `to_pairs` is not defined on `tuple[Any, Any]` in union `tuple[Any, Any] | Any`
- static_frame/test/unit/test_frame_iter.py:1549:26: error[unresolved-attribute] Attribute `tolist` is not defined on `tuple[Any, Any]` in union `Any | tuple[Any, Any]`
+ static_frame/test/unit/test_frame_iter.py:1549:26: error[unresolved-attribute] Attribute `tolist` is not defined on `tuple[Any, Any]` in union `tuple[Any, Any] | Any`
- static_frame/test/unit/test_frame_iter.py:1550:26: error[unresolved-attribute] Attribute `tolist` is not defined on `tuple[Any, Any]` in union `Any | tuple[Any, Any]`
+ static_frame/test/unit/test_frame_iter.py:1550:26: error[unresolved-attribute] Attribute `tolist` is not defined on `tuple[Any, Any]` in union `tuple[Any, Any] | Any`
- static_frame/test/unit/test_frame_iter.py:1553:26: error[unresolved-attribute] Attribute `tolist` is not defined on `tuple[Any, Any]` in union `Any | tuple[Any, Any]`
+ static_frame/test/unit/test_frame_iter.py:1553:26: error[unresolved-attribute] Attribute `tolist` is not defined on `tuple[Any, Any]` in union `tuple[Any, Any] | Any`
- static_frame/test/unit/test_frame_iter.py:1554:26: error[unresolved-attribute] Attribute `tolist` is not defined on `tuple[Any, Any]` in union `Any | tuple[Any, Any]`
+ static_frame/test/unit/test_frame_iter.py:1554:26: error[unresolved-attribute] Attribute `tolist` is not defined on `tuple[Any, Any]` in union `tuple[Any, Any] | Any`
- static_frame/test/unit/test_frame_iter.py:1684:29: error[unresolved-attribute] Attribute `shape` is not defined on `tuple[Any, Any]` in union `Any | tuple[Any, Any]`
+ static_frame/test/unit/test_frame_iter.py:1684:29: error[unresolved-attribute] Attribute `shape` is not defined on `tuple[Any, Any]` in union `tuple[Any, Any] | Any`

jax (https://github.com/google/jax)
- jax/_src/export/_export.py:1376:45: error[invalid-argument-type] Argument to function `_get_named_sharding` is incorrect: Expected `ShapedArray`, found `AbstractValue | Unknown`
+ jax/_src/export/_export.py:1376:45: error[invalid-argument-type] Argument to function `_get_named_sharding` is incorrect: Expected `ShapedArray`, found `Unknown | AbstractValue`
- jax/_src/pallas/hlo_interpreter.py:437:37: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `int | DynamicGridDim | Unknown`
+ jax/_src/pallas/hlo_interpreter.py:437:37: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `DynamicGridDim | Unknown | int`
- jax/_src/pallas/mosaic/interpret/interpret_pallas_call.py:1895:37: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `int | DynamicGridDim | Unknown`
+ jax/_src/pallas/mosaic/interpret/interpret_pallas_call.py:1895:37: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `DynamicGridDim | Unknown | int`
- jax/_src/pallas/pallas_call.py:835:37: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `int | DynamicGridDim | Unknown`
+ jax/_src/pallas/pallas_call.py:835:37: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `DynamicGridDim | Unknown | int`
- jax/collect_profile.py:110:17: error[unresolved-attribute] Attribute `glob` is not defined on `PathLike[str]`, `int`, `str`, `bytes`, `PathLike[bytes]` in union `PathLike[str] | Unknown | int | ... omitted 3 union elements`
+ jax/collect_profile.py:110:17: error[unresolved-attribute] Attribute `glob` is not defined on `PathLike[str]`, `int`, `str`, `bytes`, `PathLike[bytes]` in union `Unknown | PathLike[str] | int | ... omitted 3 union elements`
- jax/collect_profile.py:113:22: error[unsupported-operator] Operator `/` is not supported between objects of type `PathLike[str] | Unknown | int | ... omitted 3 union elements` and `Literal["remote.trace.json.gz"]`
+ jax/collect_profile.py:113:22: error[unsupported-operator] Operator `/` is not supported between objects of type `Unknown | PathLike[str] | int | ... omitted 3 union elements` and `Literal["remote.trace.json.gz"]`

scikit-learn (https://github.com/scikit-learn/scikit-learn)
- sklearn/utils/tests/test_multiclass.py:399:27: error[unresolved-attribute] Attribute `toarray` is not defined on `list[Unknown | list[Unknown | int]] & SparseABC`, `ndarray[tuple[Any, ...], dtype[Any]] & SparseABC`, `_NotAnArray & SparseABC`, `list[Unknown | int] & SparseABC`, `list[Unknown | str] & SparseABC`, `list[Unknown | list[Unknown | str]] & SparseABC`, `list[Unknown] & SparseABC`, `list[Unknown | int | float] & SparseABC`, `list[Unknown | list[Unknown]] & SparseABC`, `list[Unknown | tuple[()]] & SparseABC`, `list[Unknown | ndarray[tuple[Any, ...], dtype[Unknown]]] & SparseABC`, `list[Unknown | set[Unknown | int]] & SparseABC`, `list[Unknown | frozenset[Unknown | int]] & SparseABC`, `list[Unknown | dict[Unknown | int, Unknown | str]] & SparseABC` in union `(Unknown & SparseABC) | (list[Unknown | list[Unknown | int]] & SparseABC) | (ndarray[tuple[Any, ...], dtype[Any]] & SparseABC) | ... omitted 12 union elements`
+ sklearn/utils/tests/test_multiclass.py:399:27: error[unresolved-attribute] Attribute `toarray` is not defined on `list[Unknown | list[Unknown | int]] & SparseABC`, `ndarray[tuple[Any, ...], dtype[Any]] & SparseABC`, `_NotAnArray & SparseABC`, `list[Unknown | int] & SparseABC`, `list[Unknown | str] & SparseABC`, `list[Unknown | list[Unknown | str]] & SparseABC`, `list[Unknown] & SparseABC`, `list[Unknown | int | float] & SparseABC`, `list[Unknown | list[Unknown]] & SparseABC`, `list[Unknown | tuple[()]] & SparseABC`, `list[Unknown | ndarray[tuple[Any, ...], dtype[Unknown]]] & SparseABC`, `list[Unknown | set[Unknown | int]] & SparseABC`, `list[Unknown | frozenset[int | Unknown]] & SparseABC`, `list[Unknown | dict[Unknown | int, Unknown | str]] & SparseABC` in union `(Unknown & SparseABC) | (list[Unknown | list[Unknown | int]] & SparseABC) | (ndarray[tuple[Any, ...], dtype[Any]] & SparseABC) | ... omitted 12 union elements`

sympy (https://github.com/sympy/sympy)
- sympy/geometry/tests/test_util.py:128:55: error[invalid-argument-type] Argument to function `subsets` is incorrect: Expected `Sequence[Unknown]`, found `set[Point2D | Unknown]`
+ sympy/geometry/tests/test_util.py:128:55: error[invalid-argument-type] Argument to function `subsets` is incorrect: Expected `Sequence[Unknown]`, found `set[Unknown | Point2D]`
- sympy/integrals/prde.py:89:11: error[unresolved-attribute] Attribute `as_poly` is not defined on `int` in union `Unknown | int`
+ sympy/integrals/prde.py:89:11: error[unresolved-attribute] Attribute `as_poly` is not defined on `int` in union `int | Unknown`
- sympy/integrals/prde.py:89:61: error[unresolved-attribute] Attribute `as_poly` is not defined on `int` in union `Unknown | int`
+ sympy/integrals/prde.py:89:61: error[unresolved-attribute] Attribute `as_poly` is not defined on `int` in union `int | Unknown`
- sympy/integrals/prde.py:90:10: error[unresolved-attribute] Attribute `as_poly` is not defined on `int` in union `Unknown | int`
+ sympy/integrals/prde.py:90:10: error[unresolved-attribute] Attribute `as_poly` is not defined on `int` in union `int | Unknown`
- sympy/tensor/indexed.py:650:12: error[unresolved-attribute] Attribute `is_Number` is not defined on `None`, `int`, `float`, `complex` in union `None | Any | Basic | ... omitted 3 union elements`
+ sympy/tensor/indexed.py:650:12: error[unresolved-attribute] Attribute `is_Number` is not defined on `int`, `float`, `complex`, `None` in union `Any | Basic | int | ... omitted 3 union elements`
- sympy/tensor/indexed.py:651:20: error[unresolved-attribute] Attribute `is_integer` is not defined on `None`, `int`, `complex` in union `None | Any | Basic | ... omitted 3 union elements`
+ sympy/tensor/indexed.py:651:20: error[unresolved-attribute] Attribute `is_integer` is not defined on `int`, `complex`, `None` in union `Any | Basic | int | ... omitted 3 union elements`
- sympy/tensor/indexed.py:655:16: error[unresolved-attribute] Attribute `is_integer` is not defined on `None`, `int`, `complex` in union `None | Any | Basic | ... omitted 3 union elements`
+ sympy/tensor/indexed.py:655:16: error[unresolved-attribute] Attribute `is_integer` is not defined on `int`, `complex`, `None` in union `Any | Basic | int | ... omitted 3 union elements`
- sympy/tensor/indexed.py:678:33: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Basic`, found `None | Any | Basic | ... omitted 3 union elements`
+ sympy/tensor/indexed.py:678:33: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Basic`, found `Any | Basic | int | ... omitted 3 union elements`

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Feb 15, 2026

Memory usage report

Memory usage unchanged ✅

@charliermarsh charliermarsh marked this pull request as ready for review February 15, 2026 21:15
@charliermarsh charliermarsh marked this pull request as draft February 16, 2026 15:28
Base automatically changed from charlie/iter to main March 4, 2026 02:06
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Mar 25, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-argument-type 0 27 2
missing-argument 23 0 0
no-matching-overload 2 0 0
too-many-positional-arguments 1 0 0
unused-ignore-comment 1 0 0
unused-type-ignore-comment 1 0 0
Total 28 27 2
Raw diff (57 changes)
aiortc (https://github.com/aiortc/aiortc)
- src/aiortc/rtcrtpreceiver.py:476:43 error[invalid-argument-type] Argument to function `pack_remb_fci` is incorrect: Expected `int`, found `Unknown | int | list[int]`
- src/aiortc/rtcrtpreceiver.py:476:43 error[invalid-argument-type] Argument to function `pack_remb_fci` is incorrect: Expected `list[int]`, found `Unknown | int | list[int]`

comtypes (https://github.com/enthought/comtypes)
+ comtypes/_memberspec.py:73:61 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive

core (https://github.com/home-assistant/core)
+ homeassistant/components/govee_light_local/light.py:226:27 error[missing-argument] No arguments provided for required parameters `green`, `blue` of bound method `set_rgb_color`
+ homeassistant/components/govee_light_local/light.py:228:74 error[too-many-positional-arguments] Too many positional arguments to bound method `set_temperature`: expected 3, got 4

dedupe (https://github.com/dedupeio/dedupe)
- dedupe/core.py:196:41 error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Unknown]`, found `int | str`
+ dedupe/core.py:196:37 error[no-matching-overload] No overload of function `__new__` matches arguments

pandera (https://github.com/pandera-dev/pandera)
- pandera/backends/ibis/container.py:94:29 error[invalid-argument-type] Argument to bound method `run_schema_component_checks` is incorrect: Expected `Iterable[Unknown]`, found `Unknown | DataFrameSchema | ColumnInfo | bool`
- pandera/backends/ibis/container.py:94:29 error[invalid-argument-type] Argument to bound method `run_schema_component_checks` is incorrect: Expected `bool`, found `Unknown | DataFrameSchema | ColumnInfo | bool`
+ pandera/backends/ibis/container.py:94:23 error[missing-argument] No arguments provided for required parameters `schema_components`, `lazy` of bound method `run_schema_component_checks`
+ pandera/backends/pandas/container.py:182:23 error[missing-argument] No arguments provided for required parameters `schema_components`, `lazy` of bound method `run_schema_component_checks`
- pandera/backends/polars/container.py:118:29 error[invalid-argument-type] Argument to bound method `run_schema_component_checks` is incorrect: Expected `bool`, found `Unknown | DataFrameSchema | bool`
- pandera/backends/polars/container.py:118:29 error[invalid-argument-type] Argument to bound method `run_schema_component_checks` is incorrect: Expected `list[Unknown]`, found `Unknown | DataFrameSchema | bool`
+ pandera/backends/polars/container.py:118:23 error[missing-argument] No arguments provided for required parameters `schema_components`, `lazy` of bound method `run_schema_component_checks`
- pandera/backends/pyspark/container.py:118:29 error[invalid-argument-type] Argument to bound method `run_schema_component_checks` is incorrect: Expected `bool`, found `Unknown | ColumnInfo | bool`
- pandera/backends/pyspark/container.py:118:29 error[invalid-argument-type] Argument to bound method `run_schema_component_checks` is incorrect: Expected `list[Unknown]`, found `Unknown | ColumnInfo | bool`
+ pandera/backends/pyspark/container.py:118:23 error[missing-argument] No arguments provided for required parameters `schema_components`, `lazy` of bound method `run_schema_component_checks`

pip (https://github.com/pypa/pip)
- src/pip/_internal/index/package_finder.py:740:32 error[invalid-argument-type] Argument to function `build_netloc` is incorrect: Expected `int | None`, found `Unknown | str | int | None`
- src/pip/_internal/index/package_finder.py:740:32 error[invalid-argument-type] Argument to function `build_netloc` is incorrect: Expected `str`, found `Unknown | str | int | None`

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/server/orchestration/rules.py:651:46 error[invalid-argument-type] Argument to bound method `before_transition` is incorrect: Expected `OrchestrationContext[T@BaseOrchestrationRule, RP@BaseOrchestrationRule]`, found `Unknown | State | None | OrchestrationContext[T@BaseOrchestrationRule, RP@BaseOrchestrationRule]`
- src/prefect/server/orchestration/rules.py:651:46 error[invalid-argument-type] Argument to bound method `before_transition` is incorrect: Expected `State | None`, found `Unknown | State | None | OrchestrationContext[T@BaseOrchestrationRule, RP@BaseOrchestrationRule]`
- src/prefect/server/orchestration/rules.py:691:32 error[invalid-argument-type] Argument to bound method `cleanup` is incorrect: Expected `OrchestrationContext[T@BaseOrchestrationRule, RP@BaseOrchestrationRule]`, found `Unknown | State | None | OrchestrationContext[T@BaseOrchestrationRule, RP@BaseOrchestrationRule]`
- src/prefect/server/orchestration/rules.py:691:32 error[invalid-argument-type] Argument to bound method `cleanup` is incorrect: Expected `State | None`, found `Unknown | State | None | OrchestrationContext[T@BaseOrchestrationRule, RP@BaseOrchestrationRule]`
- src/prefect/server/orchestration/rules.py:693:41 error[invalid-argument-type] Argument to bound method `after_transition` is incorrect: Expected `OrchestrationContext[T@BaseOrchestrationRule, RP@BaseOrchestrationRule]`, found `Unknown | State | None | OrchestrationContext[T@BaseOrchestrationRule, RP@BaseOrchestrationRule]`
- src/prefect/server/orchestration/rules.py:693:41 error[invalid-argument-type] Argument to bound method `after_transition` is incorrect: Expected `State | None`, found `Unknown | State | None | OrchestrationContext[T@BaseOrchestrationRule, RP@BaseOrchestrationRule]`

pylint (https://github.com/pycqa/pylint)
- pylint/checkers/base/name_checker/checker.py:370:59 error[invalid-argument-type] Argument to bound method `_raise_name_warning` is incorrect: Expected `Confidence`, found `Unknown | str | Confidence`
- pylint/checkers/base/name_checker/checker.py:370:59 error[invalid-argument-type] Argument to bound method `_raise_name_warning` is incorrect: Expected `str`, found `Unknown | str | Confidence`
- pylint/checkers/base/name_checker/checker.py:370:59 error[invalid-argument-type] Argument to bound method `_raise_name_warning` is incorrect: Expected `str`, found `Unknown | str | Confidence`
- pylint/checkers/base/name_checker/checker.py:370:59 error[invalid-argument-type] Argument to bound method `_raise_name_warning` is incorrect: Expected `str`, found `Unknown | str | Confidence`

pytest (https://github.com/pytest-dev/pytest)
- src/_pytest/terminal.py:665:51 error[invalid-argument-type] Argument to bound method `_locationline` is incorrect: Expected `int | None`, found `str | int | None`
- src/_pytest/terminal.py:665:51 error[invalid-argument-type] Argument to bound method `_locationline` is incorrect: Expected `str`, found `str | int | None`
- src/_pytest/terminal.py:665:51 error[invalid-argument-type] Argument to bound method `_locationline` is incorrect: Expected `str`, found `str | int | None`

pytest-robotframework (https://github.com/detachhead/pytest-robotframework)
+ tests/conftest.py:299:18 error[no-matching-overload] No overload of bound method `run_pytest` matches arguments
+ tests/conftest.py:299:132 warning[unused-ignore-comment] Unused `ty: ignore` directive

scipy (https://github.com/scipy/scipy)
+ scipy/signal/tests/test_filter_design.py:4362:16 error[missing-argument] No argument provided for required parameter `Wn`
+ scipy/signal/tests/test_filter_design.py:4362:16 error[missing-argument] No argument provided for required parameter `Wn`
+ scipy/signal/tests/test_filter_design.py:4362:16 error[missing-argument] No arguments provided for required parameters `rs`, `Wn`
+ scipy/signal/tests/test_filter_design.py:4363:15 error[missing-argument] No argument provided for required parameter `Wn`
+ scipy/signal/tests/test_filter_design.py:4363:15 error[missing-argument] No argument provided for required parameter `Wn`
+ scipy/signal/tests/test_filter_design.py:4363:15 error[missing-argument] No arguments provided for required parameters `rs`, `Wn`
+ scipy/signal/tests/test_filter_design.py:4366:15 error[missing-argument] No argument provided for required parameter `Wn`
+ scipy/signal/tests/test_filter_design.py:4366:15 error[missing-argument] No argument provided for required parameter `Wn`
+ scipy/signal/tests/test_filter_design.py:4366:15 error[missing-argument] No arguments provided for required parameters `rs`, `Wn`
+ scipy/signal/tests/test_filter_design.py:4367:15 error[missing-argument] No argument provided for required parameter `Wn`
+ scipy/signal/tests/test_filter_design.py:4367:15 error[missing-argument] No argument provided for required parameter `Wn`
+ scipy/signal/tests/test_filter_design.py:4367:15 error[missing-argument] No arguments provided for required parameters `rs`, `Wn`
+ scipy/signal/tests/test_filter_design.py:4370:15 error[missing-argument] No argument provided for required parameter `Wn`
+ scipy/signal/tests/test_filter_design.py:4370:15 error[missing-argument] No argument provided for required parameter `Wn`
+ scipy/signal/tests/test_filter_design.py:4370:15 error[missing-argument] No arguments provided for required parameters `rs`, `Wn`
+ scipy/signal/tests/test_filter_design.py:4371:15 error[missing-argument] No argument provided for required parameter `Wn`
+ scipy/signal/tests/test_filter_design.py:4371:15 error[missing-argument] No argument provided for required parameter `Wn`
+ scipy/signal/tests/test_filter_design.py:4371:15 error[missing-argument] No arguments provided for required parameters `rs`, `Wn`

tornado (https://github.com/tornadoweb/tornado)
- tornado/routing.py:349:55 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, Any] | None`, found `@Todo | dict[str, Any] | str`
- tornado/routing.py:349:55 error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str | None`, found `@Todo | dict[str, Any] | str`

werkzeug (https://github.com/pallets/werkzeug)
- src/werkzeug/test.py:418:38 error[invalid-argument-type] Argument to bound method `add_file` is incorrect: Expected `str | None`, found `bytes | IO[bytes] | str`
+ src/werkzeug/test.py:418:38 error[invalid-argument-type] Argument to bound method `add_file` is incorrect: Expected `str | None`, found `bytes | str`
- src/werkzeug/test.py:418:38 error[invalid-argument-type] Argument to bound method `add_file` is incorrect: Expected `str | None`, found `bytes | IO[bytes] | str`
+ src/werkzeug/test.py:418:38 error[invalid-argument-type] Argument to bound method `add_file` is incorrect: Expected `str | PathLike[str] | IO[bytes] | FileStorage`, found `bytes | IO[bytes]`
- src/werkzeug/test.py:418:38 error[invalid-argument-type] Argument to bound method `add_file` is incorrect: Expected `str | PathLike[str] | IO[bytes] | FileStorage`, found `bytes | IO[bytes] | str`

Full report with detailed diff (timing results)

@charliermarsh charliermarsh marked this pull request as ready for review March 25, 2026 03:00
Copy link
Copy Markdown
Member

@dcreager dcreager left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

@carljm
Copy link
Copy Markdown
Contributor

carljm commented Mar 25, 2026

Not good yet, don't merge -- found some issues locally and fixing them up.

@carljm
Copy link
Copy Markdown
Contributor

carljm commented Mar 25, 2026

Ok, so I found that we were being too lax in our treatment of unions of tuples here; if a function accepts two arguments, or requires three arguments, either way calling it with an unpacked union of a 2-tuple and 3-tuple should fail due to arity.

Fixing this then exposed another issue, which is that when we have an unpacked union argument, we need to ensure that we expand that union before concluding that any overloads can be eliminated by arity checking.

There's a fair amount of new changes here, so going to request re-review.

@carljm carljm requested a review from dcreager March 25, 2026 19:38
target: "ty_python_semantic::types::call::bind",
matching_overload_index = ?self.matching_overload_index(),
"after step 4",
);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intend to keep this and the other trace calls?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of them are new, just moved / indented. So yeah, it wasn't my intent to add or remove any tracing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swear I looked!

@charliermarsh
Copy link
Copy Markdown
Member Author

(I can't approve, but feel free to proceed with merge.)

@carljm
Copy link
Copy Markdown
Contributor

carljm commented Mar 25, 2026

Did some ecosystem analysis here; all the diagnostic changes look reasonable. Some of the added diagnostics are cases where a union of functions is called with an unpacked union of tuples, and in reality there's an invariant where each function is lined up with a different tuple, but that's not a correlation we can see through. It seems like mypy is pretty lax with unpacking unions of tuples, but our results here line up with pyright and pyrefly reasonably well.

@carljm carljm merged commit 1535879 into main Mar 25, 2026
49 checks passed
@carljm carljm deleted the charlie/iter-2 branch March 25, 2026 21:39
carljm added a commit that referenced this pull request Mar 31, 2026
* main:
  [ty] Relax union variadic guard to check only parameters beyond minimum length (#23298)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants