Skip to content

Conversation

@AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood 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
more-itertools (https://github.com/more-itertools/more-itertools)
+ more_itertools/more.pyi:215:16: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ more_itertools/more.pyi:216:15: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ more_itertools/more.pyi:218:23: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ more_itertools/more.pyi:638:42: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ more_itertools/more.pyi:642:52: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
- Found 24 diagnostics
+ Found 29 diagnostics

pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/_code/code.py:676:34: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ src/_pytest/_code/code.py:789:29: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ src/_pytest/_code/code.py:818:29: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
- Found 481 diagnostics
+ Found 484 diagnostics

Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/annotations.py:389:42: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ tanjun/annotations.py:414:45: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ tanjun/annotations.py:600:41: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ tanjun/annotations.py:615:41: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ tanjun/annotations.py:629:41: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ tanjun/annotations.py:2263:21: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ tanjun/annotations.py:2263:62: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ tanjun/annotations.py:2276:38: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ tanjun/annotations.py:2276:72: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ tanjun/annotations.py:2289:53: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ tanjun/annotations.py:2371:50: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
- Found 145 diagnostics
+ Found 156 diagnostics

trio (https://github.com/python-trio/trio)
+ src/trio/_core/_traps.py:67:10: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ src/trio/_core/_traps.py:68:16: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ src/trio/_core/_traps.py:75:16: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
- Found 592 diagnostics
+ Found 595 diagnostics

django-stubs (https://github.com/typeddjango/django-stubs)
+ django-stubs/test/utils.pyi:23:28: error[invalid-type-form] Variable of type `_SpecialForm` is not allowed in a type expression
- Found 480 diagnostics
+ Found 481 diagnostics

bokeh (https://github.com/bokeh/bokeh)
+ src/bokeh/embed/standalone.py:137:49: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ src/bokeh/embed/standalone.py:140:12: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ src/bokeh/embed/standalone.py:144:49: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ src/bokeh/embed/standalone.py:147:12: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ src/bokeh/embed/standalone.py:151:49: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ src/bokeh/embed/standalone.py:154:12: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ src/bokeh/embed/standalone.py:157:52: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ src/bokeh/embed/standalone.py:299:22: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ src/bokeh/embed/standalone.py:370:62: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
- Found 616 diagnostics
+ Found 625 diagnostics

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ pandas-stubs/_typing.pyi:506:49: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ pandas-stubs/_typing.pyi:526:56: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ pandas-stubs/_typing.pyi:526:64: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ pandas-stubs/_typing.pyi:911:26: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ pandas-stubs/_typing.pyi:913:26: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ pandas-stubs/_typing.pyi:914:40: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ pandas-stubs/_typing.pyi:916:28: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ pandas-stubs/_typing.pyi:918:36: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ pandas-stubs/_typing.pyi:919:26: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
+ pandas-stubs/_typing.pyi:932:5: error[invalid-type-form] Variable of type `UnionType` is not allowed in a type expression
- Found 5415 diagnostics
+ Found 5425 diagnostics
No memory usage changes detected ✅

@AlexWaygood AlexWaygood force-pushed the alex/fix-union-wildcards branch 2 times, most recently from a1eaa77 to 91933c2 Compare November 4, 2025 21:09
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-type-form 42 0 0
Total 42 0 0

Full report with detailed diff (timing results)

@AlexWaygood
Copy link
Member Author

Nearly all the new diagnostics are false positive due to things like X = type[str] | int. We already have false positives like this on main (#21195 (comment)) and I think @sharkdp is planning on prioritising adding support for this kind of pattern in implicit type aliases

@AlexWaygood AlexWaygood marked this pull request as ready for review November 4, 2025 21:23
@AlexWaygood AlexWaygood force-pushed the alex/fix-union-wildcards branch 2 times, most recently from 7e51bdf to 88344fb Compare November 4, 2025 21:39
@AlexWaygood AlexWaygood force-pushed the alex/fix-union-wildcards branch from 88344fb to 8af56b7 Compare November 4, 2025 21:41
Copy link
Contributor

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you!

Comment on lines +8512 to +8514
Some(Type::KnownInstance(KnownInstanceType::UnionType(
UnionTypeInstance::new(self.db(), left_ty, right_ty),
)))
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm slightly confused why we don't need the convert_none_type anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because of #21263!

Copy link
Contributor

Choose a reason for hiding this comment

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

🙈

@AlexWaygood AlexWaygood merged commit f189aad into main Nov 6, 2025
41 checks passed
@AlexWaygood AlexWaygood deleted the alex/fix-union-wildcards branch November 6, 2025 14:00
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)
  ...
dcreager added a commit that referenced this pull request Nov 7, 2025
* origin/main:
  Remove duplicate preview tests for `FURB101` and `FURB103` (#21303)
  [ty] Add support for `Literal`s in implicit type aliases (#21296)
  [ty] Add missing `heap_size` to `variance_of` queries (#21318)
  [`pyupgrade`] Fix false positive on relative imports from local `.builtins` module (`UP029`) (#21309)
  [ty] Make range/position conversions fallible (#21297)
  Bump 0.14.4 (#21306)
  Fix main by using `infer_expression` (#21299)
  [ty] Understand legacy and PEP 695 `ParamSpec` (#21139)
  [ty] Discover site-packages from the environment that ty is installed in (#21286)
  [ty] Make special cases for `UnionType` slightly narrower (#21276)
  Require ignore 0.4.24 in `Cargo.toml` (#21292)
  [ty] Favour imported symbols over builtin symbols (#21285)
  docs: revise Ruff setup instructions for Zed editor (#20935)
  [ty] Update salsa (#21281)
  [syntax-error]: no binding for nonlocal  PLE0117 as a semantic syntax error (#21032)
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.

Incorrect evaluation of | between classes and non-classes

3 participants