Skip to content

Conversation

@ibraheemdev
Copy link
Member

@ibraheemdev ibraheemdev commented Nov 4, 2025

Summary

Splitting this one out from #21210. This is also something that should be made obselete by the new constraint solver, but is easy enough to fix now.

@ibraheemdev ibraheemdev requested a review from carljm as a code owner November 4, 2025 17:21
@ibraheemdev ibraheemdev added the ty Multi-file analysis & type inference label Nov 4, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

mypy_primer results

Changes were detected when running on open source projects
attrs (https://github.com/python-attrs/attrs)
- tests/test_validators.py:185:68: error[invalid-argument-type] Argument to function `matches_re` is incorrect: Expected `((Literal["a"], Literal["a"], int, /) -> Match[Literal["a"]] | None) | None`, found `Overload[(pattern: str | Pattern[str], string: str, flags: Unknown = Literal[0]) -> Match[str] | None, (pattern: bytes | Pattern[bytes], string: @Todo, flags: Unknown = Literal[0]) -> Match[bytes] | None]`
- tests/test_validators.py:219:56: error[invalid-argument-type] Argument to function `matches_re` is incorrect: Expected `((Literal["a"], Literal["a"], int, /) -> Match[Literal["a"]] | None) | None`, found `Overload[(pattern: str | Pattern[str], string: str, flags: Unknown = Literal[0]) -> Match[str] | None, (pattern: bytes | Pattern[bytes], string: @Todo, flags: Unknown = Literal[0]) -> Match[bytes] | None]`
- tests/test_validators.py:228:32: error[invalid-argument-type] Argument to function `matches_re` is incorrect: Expected `((Literal["a"], Literal["a"], int, /) -> Match[Literal["a"]] | None) | None`, found `() -> Unknown`
+ tests/test_validators.py:228:32: error[invalid-argument-type] Argument to function `matches_re` is incorrect: Expected `((str, str, int, /) -> Match[str] | None) | None`, found `() -> Unknown`
- typing-examples/mypy.py:250:64: error[invalid-argument-type] Argument to function `matches_re` is incorrect: Expected `((Literal["foo"], Literal["foo"], int, /) -> Match[Literal["foo"]] | None) | None`, found `Overload[(pattern: str | Pattern[str], string: str, flags: Unknown = Literal[0]) -> Match[str] | None, (pattern: bytes | Pattern[bytes], string: @Todo, flags: Unknown = Literal[0]) -> Match[bytes] | None]`
- Found 587 diagnostics
+ Found 584 diagnostics

scrapy (https://github.com/scrapy/scrapy)
+ tests/test_http_request.py:1428:21: error[invalid-argument-type] Argument to function `parse_qs` is incorrect: Argument type `bytes | str` does not satisfy constraints (`str`, `bytes`) of type variable `AnyStr`
- Found 1699 diagnostics
+ Found 1700 diagnostics

schemathesis (https://github.com/schemathesis/schemathesis)
- src/schemathesis/specs/openapi/checks.py:644:37: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 254 diagnostics
+ Found 253 diagnostics

tornado (https://github.com/tornadoweb/tornado)
- tornado/test/httputil_test.py:91:30: error[invalid-argument-type] Argument to function `qs_to_qsl` is incorrect: Expected `dict[str, list[str]]`, found `dict[Literal["a=1&b=2&a=3"], list[Literal["a=1&b=2&a=3"]]]`
- Found 332 diagnostics
+ Found 331 diagnostics

optuna (https://github.com/optuna/optuna)
- optuna/_gp/search_space.py:74:21: error[invalid-argument-type] Argument to function `_normalize_one_param` is incorrect: Expected `tuple[int | float, int | float]`, found `tuple[Unknown | ndarray[Unknown, <class 'float'>], Unknown | ndarray[Unknown, <class 'float'>]]`
- optuna/_gp/search_space.py:75:21: error[invalid-argument-type] Argument to function `_normalize_one_param` is incorrect: Expected `int | float`, found `Unknown | ndarray[Unknown, <class 'float'>]`
- optuna/_gp/search_space.py:104:21: error[invalid-argument-type] Argument to function `_normalize_one_param` is incorrect: Expected `tuple[int | float, int | float]`, found `tuple[Unknown | ndarray[Unknown, <class 'float'>], Unknown | ndarray[Unknown, <class 'float'>]]`
- optuna/_gp/search_space.py:105:21: error[invalid-argument-type] Argument to function `_normalize_one_param` is incorrect: Expected `int | float`, found `Unknown | ndarray[Unknown, <class 'float'>]`
- optuna/_gp/search_space.py:181:53: error[invalid-argument-type] Argument to function `_round_one_normalized_param` is incorrect: Expected `tuple[int | float, int | float]`, found `tuple[Unknown | ndarray[Unknown, <class 'float'>], Unknown | ndarray[Unknown, <class 'float'>]]`
- optuna/_gp/search_space.py:181:83: error[invalid-argument-type] Argument to function `_round_one_normalized_param` is incorrect: Expected `int | float`, found `Unknown | ndarray[Unknown, <class 'float'>]`
- tests/gp_tests/test_search_space.py:109:13: error[invalid-argument-type] Argument to function `_unnormalize_one_param` is incorrect: Expected `tuple[int | float, int | float]`, found `Unknown | ndarray[Unknown, <class 'float'>]`
- tests/gp_tests/test_search_space.py:110:13: error[invalid-argument-type] Argument to function `_unnormalize_one_param` is incorrect: Expected `int | float`, found `Unknown | ndarray[Unknown, <class 'float'>]`
- Found 583 diagnostics
+ Found 575 diagnostics

xarray (https://github.com/pydata/xarray)
+ xarray/coding/strings.py:180:13: error[invalid-argument-type] Argument to bound method `map_blocks` is incorrect: Argument type `Literal["S1"]` does not satisfy upper bound `dtype[Any]` of type variable `_DType_co`
- Found 1747 diagnostics
+ Found 1748 diagnostics

meson (https://github.com/mesonbuild/meson)
- mesonbuild/interpreter/type_checking.py:307:1: error[invalid-assignment] Object of type `KwargInfo[dict[Unknown, Unknown]]` is not assignable to `KwargInfo[str | list[str] | dict[str, @Todo]]`
- unittests/internaltests.py:1446:88: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[list[Unknown] | ContainerTypeInfo | type, str | tuple[str, str]] | None`, found `dict[Unknown | str, Unknown | str]`
- unittests/internaltests.py:1446:122: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[list[Unknown] | ContainerTypeInfo | type, str | tuple[str, str]] | None`, found `dict[Unknown | str, Unknown | str]`
- unittests/internaltests.py:1447:75: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[dict[Unknown, Unknown] | ContainerTypeInfo | type, str | tuple[str, str]] | None`, found `dict[Unknown | str, Unknown | str | tuple[str, str]]`
- unittests/internaltests.py:1447:143: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[dict[Unknown, Unknown] | ContainerTypeInfo | type, str | tuple[str, str]] | None`, found `dict[Unknown | str, Unknown | str | tuple[str, str]]`
- Found 1680 diagnostics
+ Found 1675 diagnostics

scikit-learn (https://github.com/scikit-learn/scikit-learn)
- sklearn/preprocessing/tests/test_encoders.py:846:63: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Unknown]`, found `Unknown | None | ndarray[tuple[int], <class 'object'>]`
+ sklearn/preprocessing/tests/test_encoders.py:846:63: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Unknown]`, found `Unknown | None`
- sklearn/preprocessing/tests/test_encoders.py:889:19: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Unknown]`, found `Unknown | None | ndarray[tuple[int], <class 'object'>]`
+ sklearn/preprocessing/tests/test_encoders.py:889:19: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Unknown]`, found `Unknown | None`

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/internal/ci_visibility/git_client.py:99:38: error[invalid-argument-type] Argument to function `urljoin` is incorrect: Expected `Literal["/evp_proxy/v2/api/v2/git"]`, found `Unknown | DerivedVariable[Unknown]`
+ ddtrace/internal/ci_visibility/git_client.py:99:38: error[invalid-argument-type] Argument to function `urljoin` is incorrect: Expected `str`, found `Unknown | DerivedVariable[Unknown]`

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
- tests/indexes/test_indexes.py:1577:11: error[type-assertion-failure] Argument does not have asserted type `Index[Any]`
- Found 5415 diagnostics
+ Found 5414 diagnostics

pandas (https://github.com/pandas-dev/pandas)
- pandas/core/arrays/boolean.py:259:24: warning[possibly-missing-attribute] Attribute `shape` may be missing on object of type `Unknown | None`
+ pandas/core/arrays/boolean.py:259:24: warning[possibly-missing-attribute] Attribute `shape` may be missing on object of type `@Todo | None`
- pandas/core/arrays/boolean.py:262:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[ndarray[@Todo, Unknown], ndarray[@Todo, Unknown]]`, found `tuple[@Todo | ndarray[tuple[int], <class 'bool'>], Unknown | None]`
+ pandas/core/arrays/boolean.py:262:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[ndarray[@Todo, Unknown], ndarray[@Todo, Unknown]]`, found `tuple[@Todo, @Todo | None]`
- pandas/core/internals/construction.py:254:29: error[invalid-argument-type] Argument to function `_ensure_2d` is incorrect: Expected `ndarray[@Todo, Unknown]`, found `Unknown | ExtensionArray | ndarray[@Todo, Unknown]`
- pandas/core/internals/managers.py:1165:21: warning[possibly-missing-attribute] Attribute `kind` may be missing on object of type `<class 'object'> | Unknown`
- pandas/core/internals/managers.py:1175:24: warning[possibly-missing-attribute] Attribute `kind` may be missing on object of type `<class 'object'> | Unknown`
- pandas/tests/scalar/timedelta/test_arithmetic.py:183:18: error[unsupported-operator] Operator `-` is unsupported between objects of type `Timedelta` and `timedelta64[str]`
- pandas/tests/scalar/timedelta/test_arithmetic.py:186:18: error[unsupported-operator] Operator `-` is unsupported between objects of type `timedelta64[str]` and `Timedelta`
- pandas/tests/scalar/timedelta/test_arithmetic.py:551:18: error[unsupported-operator] Operator `/` is unsupported between objects of type `timedelta64[str]` and `Timedelta`
+ pandas/tests/scalar/timedelta/test_arithmetic.py:551:18: error[unsupported-operator] Operator `/` is unsupported between objects of type `timedelta64[timedelta | int | None]` and `Timedelta`
- Found 3378 diagnostics
+ Found 3373 diagnostics

sympy (https://github.com/sympy/sympy)
+ sympy/polys/tests/test_polyclasses.py:110:12: error[unsupported-operator] Operator `+` is unsupported between objects of type `DMP[MPZ]` and `Literal[5]`
+ sympy/polys/tests/test_polyclasses.py:118:12: error[unsupported-operator] Operator `-` is unsupported between objects of type `DMP[MPZ]` and `Literal[5]`
+ sympy/polys/tests/test_polyclasses.py:126:12: error[unsupported-operator] Operator `*` is unsupported between objects of type `DMP[MPZ]` and `Literal[5]`
- Found 14459 diagnostics
+ Found 14462 diagnostics

scipy (https://github.com/scipy/scipy)
+ scipy/linalg/tests/test_basic.py:1427:29: error[no-matching-overload] No overload of function `tri` matches arguments
+ scipy/linalg/tests/test_basic.py:1439:29: error[no-matching-overload] No overload of function `tri` matches arguments
- Found 9074 diagnostics
+ Found 9076 diagnostics
No memory usage changes detected ✅

Co-authored-by: Carl Meyer <carl@astral.sh>
@ibraheemdev ibraheemdev enabled auto-merge (squash) November 5, 2025 14:59
@ibraheemdev ibraheemdev merged commit 5c69e00 into main Nov 5, 2025
40 checks passed
@ibraheemdev ibraheemdev deleted the ibraheem/typevar-unions branch November 5, 2025 15:03
carljm added a commit to MatthewMckee4/ruff that referenced this pull request Nov 6, 2025
* main: (188 commits)
  [ty] Discover site-packages from the environment that ty is installed in (astral-sh#21286)
  [ty] Make special cases for `UnionType` slightly narrower (astral-sh#21276)
  Require ignore 0.4.24 in `Cargo.toml` (astral-sh#21292)
  [ty] Favour imported symbols over builtin symbols (astral-sh#21285)
  docs: revise Ruff setup instructions for Zed editor (astral-sh#20935)
  [ty] Update salsa (astral-sh#21281)
  [syntax-error]: no binding for nonlocal  PLE0117 as a semantic syntax error (astral-sh#21032)
  [ty] Constraining a typevar with itself (possibly via union or intersection) (astral-sh#21273)
  [`ruff`] Fix false positives on starred arguments (`RUF057`) (astral-sh#21256)
  [ty] Simplify unions containing multiple type variables during inference (astral-sh#21275)
  [ty] Add `ty_server::Db` trait (astral-sh#21241)
  [ty] Refactor `Range` to/from `TextRange` conversion as prep for notebook support (astral-sh#21230)
  [ty] Fix playground crash when file name includes path separator (astral-sh#21151)
  [`refurb`] Fix false negative for underscores before sign in `Decimal` constructor (`FURB157`) (astral-sh#21190)
  [ty] Allow values of type `None` in type expressions (astral-sh#21263)
  Run codspeed benchmarks with `profiling` profile (astral-sh#21261)
  [ty] Update expected diagnostic count in benchmarks (astral-sh#21269)
  Avoid extra parentheses for long `match` patterns with `as` captures (astral-sh#21176)
  [ty] Update salsa (astral-sh#21265)
  [ty] `dict` is not assignable to `TypedDict` (astral-sh#21238)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ecosystem-analyzer ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants