Skip to content

[ty] prevent "tainted" unions in cycle normalization#23563

Merged
carljm merged 4 commits intoastral-sh:mainfrom
mtshiba:improve-cycle-normalized
Mar 10, 2026
Merged

[ty] prevent "tainted" unions in cycle normalization#23563
carljm merged 4 commits intoastral-sh:mainfrom
mtshiba:improve-cycle-normalized

Conversation

@mtshiba
Copy link
Collaborator

@mtshiba mtshiba commented Feb 25, 2026

Summary

There are some issues with our current cycle handling, particularly with our implementation of Type::cycle_normalized.

To prevent values ​​from oscillating endlessly within a fixed-point iteration, cycle_normalized unions the type of the previous iteration with the current type. This ensures monotonicity of the type inference calculation.
However, we've observed that always applying this union can sometimes produce undesirable results. Therefore, we make some exceptions where this union isn't applied (see #21909, #21910).
However, these prescriptions are likely not exhaustive, and #22794 also confirmed the occurrence of "divergent pollution" when narrowing. The core issue in #22794 is that Divergent can inhibit narrowing. The result type itself does not contain Divergent, but Divergent indirectly affects it.
This suggests that determining whether a type contains Divergent is not a perfect indicator of "taintedness".

After carefully examining these cases, I found that the problematic "low-precision types" only appear in the first few iterations: Divergent itself and the type of the next iteration constructed by referencing it. Therefore, we shouldn't union these few iterations. I found that this simple change can remove all of the exceptional handling for Divergent introduced in #21909, #21910, and #22794.

I also found that this change removes the too-many-cycle panic blocking #22633.

Test Plan

mdtest updated

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

astral-sh-bot bot commented Feb 25, 2026

Typing conformance results

No changes detected ✅

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

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 25, 2026

Memory usage report

Summary

Project Old New Diff Outcome
flake8 47.91MB 47.89MB -0.02% (10.81kB) ⬇️
trio 117.86MB 117.80MB -0.05% (58.86kB) ⬇️
sphinx 265.37MB 265.13MB -0.09% (241.72kB) ⬇️
prefect 701.70MB 701.39MB -0.04% (315.26kB) ⬇️

Significant changes

Click to expand detailed breakdown

flake8

Name Old New Diff Outcome
UnionType 103.75kB 101.25kB -2.41% (2.50kB) ⬇️
infer_definition_types 1.87MB 1.86MB -0.10% (1.97kB) ⬇️
infer_expression_types_impl 1.06MB 1.06MB -0.12% (1.31kB) ⬇️
infer_expression_type_impl 158.43kB 157.22kB -0.76% (1.21kB) ⬇️
is_redundant_with_impl::interned_arguments 141.54kB 140.51kB -0.73% (1.03kB) ⬇️
is_redundant_with_impl 141.02kB 140.46kB -0.40% (576.00B) ⬇️
all_narrowing_constraints_for_expression 82.95kB 82.51kB -0.52% (444.00B) ⬇️
loop_header_reachability 14.09kB 13.66kB -3.08% (444.00B) ⬇️
all_negative_narrowing_constraints_for_expression 40.63kB 40.30kB -0.81% (336.00B) ⬇️
IntersectionType<'db>::from_two_elements_::interned_arguments 21.23kB 20.97kB -1.21% (264.00B) ⬇️
Type<'db>::member_lookup_with_policy_ 409.34kB 409.16kB -0.05% (192.00B) ⬇️
StaticClassLiteral<'db>::implicit_attribute_inner_ 294.16kB 293.97kB -0.06% (192.00B) ⬇️
IntersectionType<'db>::from_two_elements_ 19.81kB 19.68kB -0.65% (132.00B) ⬇️
infer_unpack_types 37.99kB 37.89kB -0.28% (108.00B) ⬇️
Type<'db>::apply_specialization_::interned_arguments 202.58kB 202.50kB -0.04% (80.00B) ⬇️
... 3 more

trio

Name Old New Diff Outcome
UnionType 319.56kB 303.33kB -5.08% (16.23kB) ⬇️
infer_definition_types 7.59MB 7.58MB -0.17% (13.32kB) ⬇️
infer_expression_types_impl 7.06MB 7.06MB -0.11% (7.78kB) ⬇️
infer_expression_type_impl 1.44MB 1.43MB -0.49% (7.28kB) ⬇️
is_redundant_with_impl::interned_arguments 544.59kB 539.00kB -1.03% (5.59kB) ⬇️
loop_header_reachability 140.25kB 134.88kB -3.83% (5.37kB) ⬇️
all_narrowing_constraints_for_expression 605.86kB 601.39kB -0.74% (4.48kB) ⬇️
is_redundant_with_impl 481.92kB 479.13kB -0.58% (2.79kB) ⬇️
Type<'db>::class_member_with_policy_ 1.98MB 1.98MB +0.10% (2.10kB) ⬇️
StaticClassLiteral<'db>::implicit_attribute_inner_ 729.99kB 731.63kB +0.22% (1.64kB) ⬇️
StaticClassLiteral<'db>::implicit_attribute_inner_::interned_arguments 581.34kB 582.75kB +0.24% (1.41kB) ⬇️
all_negative_narrowing_constraints_for_expression 186.14kB 184.91kB -0.66% (1.23kB) ⬇️
Type<'db>::member_lookup_with_policy_ 1.67MB 1.67MB +0.07% (1.21kB) ⬇️
IntersectionType<'db>::from_two_elements_::interned_arguments 62.05kB 61.02kB -1.66% (1.03kB) ⬇️
Type<'db>::member_lookup_with_policy_::interned_arguments 872.32kB 871.51kB -0.09% (832.00B) ⬇️
... 12 more

sphinx

Name Old New Diff Outcome
infer_expression_types_impl 21.50MB 21.46MB -0.20% (43.78kB) ⬇️
infer_expression_type_impl 3.25MB 3.21MB -1.29% (42.76kB) ⬇️
infer_definition_types 24.05MB 24.01MB -0.17% (41.94kB) ⬇️
UnionType 1.27MB 1.23MB -2.82% (36.64kB) ⬇️
all_narrowing_constraints_for_expression 2.36MB 2.33MB -1.08% (26.00kB) ⬇️
is_redundant_with_impl::interned_arguments 2.07MB 2.06MB -0.63% (13.41kB) ⬇️
all_negative_narrowing_constraints_for_expression 1.02MB 1.01MB -1.10% (11.48kB) ⬇️
loop_header_reachability 391.20kB 380.26kB -2.80% (10.95kB) ⬇️
is_redundant_with_impl 1.81MB 1.80MB -0.38% (7.05kB) ⬇️
Type<'db>::member_lookup_with_policy_::interned_arguments 2.55MB 2.54MB -0.11% (2.84kB) ⬇️
Type<'db>::member_lookup_with_policy_ 6.10MB 6.10MB -0.04% (2.73kB) ⬇️
Type<'db>::class_member_with_policy_ 7.55MB 7.55MB +0.03% (2.63kB) ⬇️
IntersectionType<'db>::from_two_elements_::interned_arguments 179.09kB 176.95kB -1.20% (2.15kB) ⬇️
StaticClassLiteral<'db>::implicit_attribute_inner_::interned_arguments 1.90MB 1.90MB +0.08% (1.59kB) ⬇️
IntersectionType<'db>::from_two_elements_ 210.29kB 208.84kB -0.69% (1.45kB) ⬇️
... 21 more

prefect

Name Old New Diff Outcome
infer_expression_types_impl 60.40MB 60.34MB -0.10% (62.65kB) ⬇️
infer_expression_type_impl 14.34MB 14.28MB -0.41% (60.18kB) ⬇️
infer_definition_types 88.46MB 88.40MB -0.06% (58.55kB) ⬇️
UnionType 3.50MB 3.45MB -1.38% (49.36kB) ⬇️
all_narrowing_constraints_for_expression 6.97MB 6.95MB -0.29% (20.71kB) ⬇️
is_redundant_with_impl::interned_arguments 5.35MB 5.34MB -0.27% (14.70kB) ⬇️
loop_header_reachability 443.03kB 430.28kB -2.88% (12.75kB) ⬇️
all_negative_narrowing_constraints_for_expression 2.59MB 2.58MB -0.45% (11.86kB) ⬇️
is_redundant_with_impl 5.56MB 5.55MB -0.13% (7.41kB) ⬇️
Type<'db>::member_lookup_with_policy_ 15.34MB 15.34MB -0.03% (4.88kB) ⬇️
IntersectionType<'db>::from_two_elements_::interned_arguments 350.28kB 346.50kB -1.08% (3.78kB) ⬇️
Type<'db>::member_lookup_with_policy_::interned_arguments 5.51MB 5.51MB -0.06% (3.25kB) ⬇️
IntersectionType<'db>::from_two_elements_ 344.66kB 341.93kB -0.79% (2.73kB) ⬇️
StaticClassLiteral<'db>::implicit_attribute_inner_ 9.70MB 9.70MB -0.02% (2.02kB) ⬇️
Type<'db>::class_member_with_policy_ 17.20MB 17.21MB +0.01% (1.90kB) ⬇️
... 9 more

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 25, 2026

mypy_primer results

Changes were detected when running on open source projects
anyio (https://github.com/agronholm/anyio)
- src/anyio/_backends/_asyncio.py:822:34: error[unresolved-attribute] Attribute `__context__` is not defined on `None` in union `BaseException | None`
- src/anyio/_backends/_asyncio.py:823:25: error[unresolved-attribute] Attribute `__context__` is not defined on `None` in union `BaseException | None`
- Found 94 diagnostics
+ Found 92 diagnostics

aiortc (https://github.com/aiortc/aiortc)
+ src/aiortc/rtcsctptransport.py:528:15: error[unsupported-operator] Operator `<` is not supported between objects of type `int | Unknown | None` and `int`
+ src/aiortc/rtcsctptransport.py:529:21: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> DataChunk, (s: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> list[DataChunk]]` cannot be called with key of type `None` on object of type `list[DataChunk]`
+ src/aiortc/rtcsctptransport.py:536:25: error[unsupported-operator] Operator `+=` is not supported between objects of type `None` and `Literal[1]`
+ src/aiortc/rtcsctptransport.py:547:21: error[unsupported-operator] Operator `+=` is not supported between objects of type `None` and `Literal[1]`
+ src/aiortc/rtcsctptransport.py:552:71: error[unsupported-operator] Operator `+` is not supported between objects of type `int | Unknown | None` and `Literal[1]`
+ src/aiortc/rtcsctptransport.py:555:67: error[unsupported-operator] Operator `+` is not supported between objects of type `int | Unknown | None` and `Literal[1]`
+ src/aiortc/rtcsctptransport.py:562:17: error[unsupported-operator] Operator `+=` is not supported between objects of type `None` and `Literal[1]`
- Found 194 diagnostics
+ Found 201 diagnostics

graphql-core (https://github.com/graphql-python/graphql-core)
- src/graphql/language/visitor.py:216:33: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Iterable[Unknown]`, found `None | Any | Node | tuple[Unknown, ...]`
+ src/graphql/language/visitor.py:216:33: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Iterable[Unknown]`, found `None | Any | Node | (tuple[Unknown, ...] & ~Node)`
- src/graphql/language/visitor.py:228:60: error[unresolved-attribute] Attribute `keys` is not defined on `None`, `tuple[Unknown, ...]` in union `None | Any | Node | tuple[Unknown, ...]`
+ src/graphql/language/visitor.py:228:60: error[unresolved-attribute] Attribute `keys` is not defined on `None`, `tuple[Unknown, ...] & ~Node` in union `None | Any | Node | (tuple[Unknown, ...] & ~Node)`

alerta (https://github.com/alerta/alerta)
- alerta/utils/api.py:125:17: error[invalid-assignment] Too many values to unpack: Expected 3
- Found 638 diagnostics
+ Found 637 diagnostics

pydantic (https://github.com/pydantic/pydantic)
- pydantic/_internal/_core_metadata.py:87:54: error[invalid-assignment] Invalid assignment to key "pydantic_js_extra" with declared type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | ((dict[str, Divergent], type[Any], /) -> None)` on TypedDict `CoreMetadata`: value of type `dict[object, object]`
+ pydantic/_internal/_core_metadata.py:87:54: error[invalid-assignment] Invalid assignment to key "pydantic_js_extra" with declared type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | ((dict[str, int | float | str | ... omitted 3 union elements], type[Any], /) -> None)` on TypedDict `CoreMetadata`: value of type `dict[object, object]`
- pydantic/fields.py:949:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:949:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:989:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:989:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1032:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1032:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1072:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1072:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1115:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1115:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1154:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1154:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1194:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`
+ pydantic/fields.py:1194:5: error[invalid-parameter-default] Default value of type `PydanticUndefinedType` is not assignable to annotated parameter type `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`
- pydantic/fields.py:1573:13: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, Divergent] | ((dict[str, Divergent], /) -> None) | None`, found `dict[str, Divergent] | dict[Never, Never] | (((dict[str, Divergent], /) -> None) & ~Top[dict[Unknown, Unknown]]) | None`
+ pydantic/fields.py:1573:13: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, int | float | str | ... omitted 3 union elements] | ((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) | None`, found `dict[str, int | float | str | ... omitted 3 union elements] | dict[Never, Never] | (((dict[str, int | float | str | ... omitted 3 union elements], /) -> None) & ~Top[dict[Unknown, Unknown]]) | None`

vision (https://github.com/pytorch/vision)
- references/depth/stereo/transforms.py:190:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[tuple[Unknown, Unknown], tuple[Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None, Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None], tuple[Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None, Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None]]`, found `tuple[tuple[Unknown, Unknown], tuple[Unknown, ...] | tuple[None, ...] | Unknown, tuple[Unknown, ...] | tuple[None, ...] | Unknown]`
+ references/depth/stereo/transforms.py:190:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[tuple[Unknown, Unknown], tuple[Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None, Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None], tuple[Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None, Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None]]`, found `tuple[tuple[Unknown, Unknown], tuple[Unknown, ...] | Unknown | tuple[None, ...], tuple[Unknown, ...] | Unknown | tuple[None, ...]]`

meson (https://github.com/mesonbuild/meson)
- mesonbuild/ast/interpreter.py:299:34: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `list[str | int | Sequence[Divergent] | ... omitted 5 union elements]`, found `BaseNode & Top[list[Unknown]]`
+ mesonbuild/ast/interpreter.py:299:34: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `list[Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements]`, found `BaseNode & Top[list[Unknown]]`
- mesonbuild/ast/interpreter.py:301:33: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, str | int | Sequence[Divergent] | ... omitted 5 union elements]`, found `BaseNode & Top[dict[Unknown, Unknown]]`
+ mesonbuild/ast/interpreter.py:301:33: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `dict[str, Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements]`, found `BaseNode & Top[dict[Unknown, Unknown]]`
- mesonbuild/ast/interpreter.py:556:48: error[invalid-argument-type] Argument to bound method `node_to_runtime_value` is incorrect: Expected `MesonInterpreterObject | BaseNode | str | ... omitted 6 union elements`, found `object`
+ mesonbuild/ast/interpreter.py:556:48: error[invalid-argument-type] Argument to bound method `node_to_runtime_value` is incorrect: Expected `MesonInterpreterObject | BaseNode | Sequence[Divergent] | ... omitted 6 union elements`, found `object`
- mesonbuild/ast/interpreter.py:731:28: error[invalid-argument-type] Argument to function `src_to_abs` is incorrect: Expected `str | IntrospectionFile | UnknownValue`, found `str | int | Sequence[Divergent] | ... omitted 5 union elements`
+ mesonbuild/ast/interpreter.py:731:28: error[invalid-argument-type] Argument to function `src_to_abs` is incorrect: Expected `str | IntrospectionFile | UnknownValue`, found `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`
- mesonbuild/interpreter/interpreter.py:1494:43: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `str | int | Sequence[Divergent] | ... omitted 5 union elements`
+ mesonbuild/interpreter/interpreter.py:1494:43: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `str`, found `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`
- mesonbuild/interpreter/interpreter.py:2277:19: error[unresolved-attribute] Attribute `get` is not defined on `EnvironmentVariables`, `list[str | int | Sequence[Divergent] | ... omitted 5 union elements]`, `str` in union `EnvironmentVariables | dict[str, str | int | Sequence[Divergent] | ... omitted 5 union elements] | list[str | int | Sequence[Divergent] | ... omitted 5 union elements] | str`
+ mesonbuild/interpreter/interpreter.py:2277:19: error[unresolved-attribute] Attribute `get` is not defined on `EnvironmentVariables`, `list[Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements]`, `str` in union `EnvironmentVariables | dict[str, Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements] | list[Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements] | str`
- mesonbuild/interpreter/interpreter.py:2283:33: error[invalid-argument-type] Argument is incorrect: Expected `EnvironmentVariables | list[Unknown] | dict[Unknown, Unknown] | str | None`, found `str | int | Sequence[Divergent] | ... omitted 5 union elements`
+ mesonbuild/interpreter/interpreter.py:2283:33: error[invalid-argument-type] Argument is incorrect: Expected `EnvironmentVariables | list[Unknown] | dict[Unknown, Unknown] | str | None`, found `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`
- mesonbuild/interpreter/interpreter.py:2308:37: error[invalid-argument-type] Argument to bound method `unpack_env_kwarg` is incorrect: Expected `EnvironmentVariables | dict[str, str | int | Sequence[Divergent] | ... omitted 5 union elements] | list[str | int | Sequence[Divergent] | ... omitted 5 union elements] | str`, found `BaseTest`
+ mesonbuild/interpreter/interpreter.py:2308:37: error[invalid-argument-type] Argument to bound method `unpack_env_kwarg` is incorrect: Expected `EnvironmentVariables | dict[str, Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements] | list[Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements] | str`, found `BaseTest`
- mesonbuild/interpreter/interpreter.py:2814:26: error[invalid-assignment] Object of type `list[str | Program]` is not assignable to `list[str | int | Sequence[Divergent] | ... omitted 5 union elements]`
+ mesonbuild/interpreter/interpreter.py:2814:26: error[invalid-assignment] Object of type `list[str | Program]` is not assignable to `list[Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements]`
- mesonbuild/interpreter/interpreter.py:2815:41: error[invalid-argument-type] Argument to bound method `run_command_impl` is incorrect: Expected `tuple[Executable | Program | Compiler | File | str, list[Executable | Program | Compiler | File | str]]`, found `tuple[str | Program, list[str | int | Sequence[Divergent] | ... omitted 5 union elements]]`
+ mesonbuild/interpreter/interpreter.py:2815:41: error[invalid-argument-type] Argument to bound method `run_command_impl` is incorrect: Expected `tuple[Executable | Program | Compiler | File | str, list[Executable | Program | Compiler | File | str]]`, found `tuple[str | Program, list[Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements]]`
- mesonbuild/interpreter/interpreter.py:3111:46: error[invalid-argument-type] Argument to function `env_convertor_with_method` is incorrect: Expected `EnvironmentVariables | list[str] | list[list[str]] | ... omitted 3 union elements`, found `str | list[str | int | Sequence[Divergent] | ... omitted 5 union elements] | dict[str, str | int | Sequence[Divergent] | ... omitted 5 union elements]`
+ mesonbuild/interpreter/interpreter.py:3111:46: error[invalid-argument-type] Argument to function `env_convertor_with_method` is incorrect: Expected `EnvironmentVariables | list[str] | list[list[str]] | ... omitted 3 union elements`, found `str | list[Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements] | dict[str, Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements]`
- mesonbuild/interpreter/interpreter.py:3111:52: error[invalid-argument-type] Argument to function `env_convertor_with_method` is incorrect: Expected `Literal["set", "prepend", "append"]`, found `str | int | Sequence[Divergent] | ... omitted 5 union elements`
+ mesonbuild/interpreter/interpreter.py:3111:52: error[invalid-argument-type] Argument to function `env_convertor_with_method` is incorrect: Expected `Literal["set", "prepend", "append"]`, found `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`
- mesonbuild/interpreter/interpreter.py:3111:70: error[invalid-argument-type] Argument to function `env_convertor_with_method` is incorrect: Expected `str`, found `str | int | Sequence[Divergent] | ... omitted 5 union elements`
+ mesonbuild/interpreter/interpreter.py:3111:70: error[invalid-argument-type] Argument to function `env_convertor_with_method` is incorrect: Expected `str`, found `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`
- mesonbuild/interpreter/interpreter.py:3709:36: error[invalid-argument-type] Argument to bound method `set_variable` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `object`
+ mesonbuild/interpreter/interpreter.py:3709:36: error[invalid-argument-type] Argument to bound method `set_variable` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `object`
- mesonbuild/interpreter/interpreter.py:3722:20: error[invalid-return-type] Return type does not match returned value: expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `InterpreterObject`
+ mesonbuild/interpreter/interpreter.py:3722:20: error[invalid-return-type] Return type does not match returned value: expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `InterpreterObject`
- mesonbuild/interpreter/interpreter.py:3725:24: error[invalid-return-type] Return type does not match returned value: expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `InterpreterObject`
+ mesonbuild/interpreter/interpreter.py:3725:24: error[invalid-return-type] Return type does not match returned value: expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `InterpreterObject`
- mesonbuild/interpreter/interpreter.py:3725:40: error[invalid-argument-type] Argument to bound method `_holderify` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `~None`
+ mesonbuild/interpreter/interpreter.py:3725:40: error[invalid-argument-type] Argument to bound method `_holderify` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `~None`
- mesonbuild/interpreter/interpreterobjects.py:967:16: error[invalid-return-type] Return type does not match returned value: expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `Unknown | str | int | ... omitted 7 union elements`
+ mesonbuild/interpreter/interpreterobjects.py:967:16: error[invalid-return-type] Return type does not match returned value: expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `Unknown | Sequence[Divergent] | int | ... omitted 7 union elements`
- mesonbuild/interpreter/primitives/array.py:59:44: error[invalid-argument-type] Argument to function `check_contains` is incorrect: Expected `list[str | int | Sequence[Divergent] | ... omitted 5 union elements]`, found `(Sequence[Divergent] & Top[list[Unknown]]) | (HoldableObject & Top[list[Unknown]]) | (MesonInterpreterObject & Top[list[Unknown]]) | (Sequence[Divergent] & Top[list[Unknown]])`
+ mesonbuild/interpreter/primitives/array.py:59:44: error[invalid-argument-type] Argument to function `check_contains` is incorrect: Expected `list[Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements]`, found `(Sequence[Divergent] & Top[list[Unknown]]) | (Sequence[Divergent] & Top[list[Unknown]]) | (HoldableObject & Top[list[Unknown]]) | (MesonInterpreterObject & Top[list[Unknown]])`
- mesonbuild/interpreter/primitives/array.py:123:40: error[invalid-argument-type] Argument to function `flatten` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `object`
+ mesonbuild/interpreter/primitives/array.py:123:40: error[invalid-argument-type] Argument to function `flatten` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `object`
- mesonbuild/interpreterbase/_unholder.py:18:16: error[invalid-return-type] Return type does not match returned value: expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `HoldableObject | int | str | Top[list[Unknown]] | Top[dict[Unknown, Unknown]]`
+ mesonbuild/interpreterbase/_unholder.py:18:16: error[invalid-return-type] Return type does not match returned value: expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `HoldableObject | int | str | Top[list[Unknown]] | Top[dict[Unknown, Unknown]]`
- mesonbuild/interpreterbase/decorators.py:45:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[BaseNode, list[str | int | Sequence[Divergent] | ... omitted 5 union elements], dict[str, str | int | Sequence[Divergent] | ... omitted 5 union elements], SubProject]`, found `tuple[Any, None | Any, None | Any, Any]`
+ mesonbuild/interpreterbase/decorators.py:45:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[BaseNode, list[Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements], dict[str, Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements], SubProject]`, found `tuple[Any, None | Any, None | Any, Any]`
- mesonbuild/interpreterbase/helpers.py:31:27: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `~Top[list[Unknown]] & ~StringNode`
+ mesonbuild/interpreterbase/helpers.py:31:27: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `~Top[list[Unknown]] & ~StringNode`
- mesonbuild/interpreterbase/helpers.py:37:30: error[invalid-argument-type] Argument to function `resolver` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `object`
+ mesonbuild/interpreterbase/helpers.py:37:30: error[invalid-argument-type] Argument to function `resolver` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `object`
- mesonbuild/interpreterbase/helpers.py:39:20: error[invalid-return-type] Return type does not match returned value: expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `dict[object, str | int | Sequence[Divergent] | ... omitted 5 union elements]`
+ mesonbuild/interpreterbase/helpers.py:39:20: error[invalid-return-type] Return type does not match returned value: expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `dict[object, Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements]`
- mesonbuild/interpreterbase/helpers.py:39:33: error[invalid-argument-type] Argument to function `resolver` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `object`
+ mesonbuild/interpreterbase/helpers.py:39:33: error[invalid-argument-type] Argument to function `resolver` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `object`
- mesonbuild/interpreterbase/helpers.py:58:59: error[invalid-argument-type] Argument to function `stringifyUserArguments` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `object`
+ mesonbuild/interpreterbase/helpers.py:58:59: error[invalid-argument-type] Argument to function `stringifyUserArguments` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `object`
- mesonbuild/interpreterbase/helpers.py:60:54: error[invalid-argument-type] Argument to function `stringifyUserArguments` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `object`
+ mesonbuild/interpreterbase/helpers.py:60:54: error[invalid-argument-type] Argument to function `stringifyUserArguments` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `object`
- mesonbuild/interpreterbase/helpers.py:61:54: error[invalid-argument-type] Argument to function `stringifyUserArguments` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `object`
+ mesonbuild/interpreterbase/helpers.py:61:54: error[invalid-argument-type] Argument to function `stringifyUserArguments` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `object`
- mesonbuild/interpreterbase/interpreterbase.py:295:67: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `None`
+ mesonbuild/interpreterbase/interpreterbase.py:295:67: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `None`
- mesonbuild/interpreterbase/interpreterbase.py:310:60: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `None`
+ mesonbuild/interpreterbase/interpreterbase.py:310:60: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `None`
- mesonbuild/interpreterbase/interpreterbase.py:363:54: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `None`
+ mesonbuild/interpreterbase/interpreterbase.py:363:54: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `None`
- mesonbuild/interpreterbase/interpreterbase.py:371:68: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `None`
+ mesonbuild/interpreterbase/interpreterbase.py:371:68: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `None`
- mesonbuild/interpreterbase/interpreterbase.py:379:54: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `None`
+ mesonbuild/interpreterbase/interpreterbase.py:379:54: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `None`
- mesonbuild/interpreterbase/interpreterbase.py:387:68: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `None`
+ mesonbuild/interpreterbase/interpreterbase.py:387:68: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `None`
- mesonbuild/interpreterbase/interpreterbase.py:396:70: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `None`
+ mesonbuild/interpreterbase/interpreterbase.py:396:70: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `None`
- mesonbuild/interpreterbase/interpreterbase.py:420:64: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `None`
+ mesonbuild/interpreterbase/interpreterbase.py:420:64: error[invalid-argument-type] Argument to bound method `operator_call` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `None`
- mesonbuild/interpreterbase/interpreterbase.py:469:79: error[invalid-argument-type] Argument to bound method `_holderify` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `object`
+ mesonbuild/interpreterbase/interpreterbase.py:469:79: error[invalid-argument-type] Argument to bound method `_holderify` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `object`
- mesonbuild/interpreterbase/interpreterbase.py:615:41: error[invalid-argument-type] Argument to bound method `_holderify` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `object`
+ mesonbuild/interpreterbase/interpreterbase.py:615:41: error[invalid-argument-type] Argument to bound method `_holderify` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `object`
- mesonbuild/interpreterbase/interpreterbase.py:632:37: error[invalid-argument-type] Argument to bound method `set_variable` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `(InterpreterObject & ~MutableInterpreterObject) | None | (InterpreterObject & MutableInterpreterObject)`
+ mesonbuild/interpreterbase/interpreterbase.py:632:37: error[invalid-argument-type] Argument to bound method `set_variable` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `(InterpreterObject & ~MutableInterpreterObject) | None | (InterpreterObject & MutableInterpreterObject)`
- mesonbuild/modules/__init__.py:263:93: error[invalid-assignment] Object of type `Sequence[str | int | Sequence[Divergent] | ... omitted 6 union elements] & Top[list[Unknown]]` is not assignable to `list[str | int | Sequence[Divergent] | ... omitted 6 union elements]`: Incompatible value of type `Sequence[str | int | Sequence[Divergent] | ... omitted 6 union elements] & Top[list[Unknown]]`
+ mesonbuild/modules/__init__.py:263:93: error[invalid-assignment] Object of type `Sequence[Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 6 union elements] & Top[list[Unknown]]` is not assignable to `list[Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 6 union elements]`: Incompatible value of type `Sequence[Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 6 union elements] & Top[list[Unknown]]`
- mesonbuild/modules/hotdoc.py:135:48: error[invalid-argument-type] Argument to bound method `check_extra_arg_type` is incorrect: Expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `object`
+ mesonbuild/modules/hotdoc.py:135:48: error[invalid-argument-type] Argument to bound method `check_extra_arg_type` is incorrect: Expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `object`
- mesonbuild/optinterpreter.py:131:20: error[invalid-return-type] Return type does not match returned value: expected `str | int | Sequence[Divergent] | ... omitted 5 union elements`, found `int | float`
+ mesonbuild/optinterpreter.py:131:20: error[invalid-return-type] Return type does not match returned value: expected `Sequence[Divergent] | int | dict[str, Divergent] | ... omitted 5 union elements`, found `int | float`
- mesonbuild/rewriter.py:774:83: error[unresolved-attribute] Object of type `(int & ~UnknownValue) | (Sequence[Divergent] & ~UnknownValue & ~str) | (dict[str, Divergent] & ~UnknownValue) | ... omitted 4 union elements` has no attribute `to_abs_path`
+ mesonbuild/rewriter.py:774:83: error[unresolved-attribute] Object of type `(Sequence[Divergent] & ~UnknownValue & ~str) | (int & ~UnknownValue) | (dict[str, Divergent] & ~UnknownValue) | ... omitted 4 union elements` has no attribute `to_abs_path`

setuptools (https://github.com/pypa/setuptools)
- setuptools/_distutils/text_file.py:232:44: error[unsupported-operator] Operator `+` is not supported between objects of type `Unknown | int | None` and `Literal[1]`
+ setuptools/_distutils/text_file.py:232:44: error[unsupported-operator] Operator `+` is not supported between objects of type `Unknown | int | None | Divergent` and `Literal[1]`
- setuptools/_distutils/text_file.py:242:41: error[unsupported-operator] Operator `+` is not supported between objects of type `Unknown | int | None` and `Literal[1]`
+ setuptools/_distutils/text_file.py:242:41: error[unsupported-operator] Operator `+` is not supported between objects of type `Unknown | int | None | Divergent` and `Literal[1]`

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/structured_configs/_implementations.py:1325:20: error[invalid-return-type] Return type does not match returned value: expected `_T@_sanitize_collection`, found `dict[int | None | float | ... omitted 12 union elements, int | None | float | ... omitted 12 union elements]`
+ src/hydra_zen/structured_configs/_implementations.py:1325:20: error[invalid-return-type] Return type does not match returned value: expected `_T@_sanitize_collection`, found `dict[int | None | float | ... omitted 9 union elements, int | None | float | ... omitted 9 union elements]`
- tests/annotations/declarations.py:929:5: error[type-assertion-failure] Type `StdBuilds[Unknown]` does not match asserted type `StdBuilds[int | None | float | ... omitted 19 union elements]`
+ tests/annotations/declarations.py:929:5: error[type-assertion-failure] Type `StdBuilds[Unknown]` does not match asserted type `StdBuilds[int | None | float | ... omitted 15 union elements]`
- tests/annotations/declarations.py:934:5: error[type-assertion-failure] Type `StdBuilds[Unknown]` does not match asserted type `StdBuilds[int | None | float | ... omitted 19 union elements]`
+ tests/annotations/declarations.py:934:5: error[type-assertion-failure] Type `StdBuilds[Unknown]` does not match asserted type `StdBuilds[int | None | float | ... omitted 15 union elements]`
- tests/annotations/declarations.py:940:5: error[type-assertion-failure] Type `PBuilds[Unknown]` does not match asserted type `PBuilds[int | None | float | ... omitted 19 union elements]`
+ tests/annotations/declarations.py:940:5: error[type-assertion-failure] Type `PBuilds[Unknown]` does not match asserted type `PBuilds[int | None | float | ... omitted 15 union elements]`
- tests/annotations/declarations.py:944:5: error[type-assertion-failure] Type `PBuilds[Unknown]` does not match asserted type `PBuilds[int | None | float | ... omitted 19 union elements]`
+ tests/annotations/declarations.py:944:5: error[type-assertion-failure] Type `PBuilds[Unknown]` does not match asserted type `PBuilds[int | None | float | ... omitted 15 union elements]`
- tests/annotations/declarations.py:945:5: error[type-assertion-failure] Type `Unknown` does not match asserted type `PBuilds[int | None | float | ... omitted 19 union elements]`
+ tests/annotations/declarations.py:945:5: error[type-assertion-failure] Type `Unknown` does not match asserted type `PBuilds[int | None | float | ... omitted 15 union elements]`
- tests/annotations/declarations.py:951:5: error[type-assertion-failure] Type `FullBuilds[Unknown] | StdBuilds[Unknown]` does not match asserted type `FullBuilds[int | None | float | ... omitted 19 union elements] | StdBuilds[int | None | float | ... omitted 19 union elements]`
+ tests/annotations/declarations.py:951:5: error[type-assertion-failure] Type `FullBuilds[Unknown] | StdBuilds[Unknown]` does not match asserted type `FullBuilds[int | None | float | ... omitted 15 union elements] | StdBuilds[int | None | float | ... omitted 15 union elements]`
- tests/annotations/declarations.py:956:5: error[type-assertion-failure] Type `PBuilds[Unknown] | StdBuilds[Unknown]` does not match asserted type `PBuilds[int | None | float | ... omitted 19 union elements] | StdBuilds[int | None | float | ... omitted 19 union elements]`
+ tests/annotations/declarations.py:956:5: error[type-assertion-failure] Type `PBuilds[Unknown] | StdBuilds[Unknown]` does not match asserted type `PBuilds[int | None | float | ... omitted 15 union elements] | StdBuilds[int | None | float | ... omitted 15 union elements]`
- tests/annotations/declarations.py:961:5: error[type-assertion-failure] Type `PBuilds[Unknown] | StdBuilds[Unknown]` does not match asserted type `PBuilds[int | None | float | ... omitted 19 union elements] | StdBuilds[int | None | float | ... omitted 19 union elements]`
+ tests/annotations/declarations.py:961:5: error[type-assertion-failure] Type `PBuilds[Unknown] | StdBuilds[Unknown]` does not match asserted type `PBuilds[int | None | float | ... omitted 15 union elements] | StdBuilds[int | None | float | ... omitted 15 union elements]`
- tests/annotations/declarations.py:969:5: error[type-assertion-failure] Type `FullBuilds[Unknown] | PBuilds[Unknown] | StdBuilds[Unknown]` does not match asserted type `FullBuilds[int | None | float | ... omitted 19 union elements] | PBuilds[int | None | float | ... omitted 19 union elements] | StdBuilds[int | None | float | ... omitted 19 union elements]`
+ tests/annotations/declarations.py:969:5: error[type-assertion-failure] Type `FullBuilds[Unknown] | PBuilds[Unknown] | StdBuilds[Unknown]` does not match asserted type `FullBuilds[int | None | float | ... omitted 15 union elements] | PBuilds[int | None | float | ... omitted 15 union elements] | StdBuilds[int | None | float | ... omitted 15 union elements]`
- tests/annotations/declarations.py:980:5: error[type-assertion-failure] Type `FullBuilds[Unknown] | PBuilds[Unknown] | StdBuilds[Unknown]` does not match asserted type `FullBuilds[int | None | float | ... omitted 19 union elements] | PBuilds[int | None | float | ... omitted 19 union elements] | StdBuilds[int | None | float | ... omitted 19 union elements]`
+ tests/annotations/declarations.py:980:5: error[type-assertion-failure] Type `FullBuilds[Unknown] | PBuilds[Unknown] | StdBuilds[Unknown]` does not match asserted type `FullBuilds[int | None | float | ... omitted 15 union elements] | PBuilds[int | None | float | ... omitted 15 union elements] | StdBuilds[int | None | float | ... omitted 15 union elements]`

sympy (https://github.com/sympy/sympy)
- sympy/combinatorics/perm_groups.py:4213:17: error[unsupported-operator] Operator `in` is not supported between objects of type `Unknown` and `None | Unknown`
+ sympy/combinatorics/perm_groups.py:4213:17: error[unsupported-operator] Operator `in` is not supported between objects of type `Unknown` and `None`
- sympy/combinatorics/perm_groups.py:4233:17: error[invalid-assignment] Invalid subscript assignment with key of type `int | Divergent` and value of type `list[Unknown]` on object of type `list[None]`
+ sympy/combinatorics/perm_groups.py:4233:17: error[invalid-assignment] Invalid subscript assignment with key of type `int` and value of type `list[Unknown]` on object of type `list[None]`
- sympy/combinatorics/perm_groups.py:4245:30: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- sympy/combinatorics/perm_groups.py:4256:17: error[unsupported-operator] Operator `in` is not supported between objects of type `Unknown` and `None | Unknown`
+ sympy/combinatorics/perm_groups.py:4256:17: error[unsupported-operator] Operator `in` is not supported between objects of type `Unknown` and `None`
- sympy/combinatorics/perm_groups.py:4292:38: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `None | Unknown`
+ sympy/combinatorics/perm_groups.py:4292:38: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `None`
- sympy/combinatorics/perm_groups.py:4300:26: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- sympy/combinatorics/perm_groups.py:4302:65: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- sympy/core/add.py:1224:28: error[unsupported-operator] Operator `not in` is not supported between objects of type `Unknown` and `None | set[Unknown]`
+ sympy/core/add.py:1224:28: error[unsupported-operator] Operator `not in` is not supported between objects of type `Unknown` and `None | set[Unknown] | (Unknown & ~AlwaysFalsy)`
- sympy/core/add.py:1230:26: error[not-iterable] Object of type `None | set[Unknown]` may not be iterable
+ sympy/core/add.py:1230:26: error[not-iterable] Object of type `None | set[Unknown] | (Unknown & ~AlwaysFalsy)` may not be iterable
- sympy/solvers/solvers.py:3176:26: error[unresolved-attribute] Attribute `as_independent` is not defined on `Basic` in union `Unknown | Divergent | Basic | Divergent`
+ sympy/solvers/solvers.py:3176:26: error[unresolved-attribute] Attribute `as_independent` is not defined on `Basic` in union `Unknown | Basic`
- sympy/solvers/solvers.py:3200:24: error[unresolved-attribute] Attribute `as_independent` is not defined on `Basic` in union `Unknown | Divergent | Basic | Divergent`
+ sympy/solvers/solvers.py:3200:24: error[unresolved-attribute] Attribute `as_independent` is not defined on `Basic` in union `Unknown | Basic`
- sympy/solvers/solvers.py:3214:21: error[unresolved-attribute] Attribute `is_polynomial` is not defined on `Basic` in union `Unknown | Divergent | Basic | Divergent`
+ sympy/solvers/solvers.py:3214:21: error[unresolved-attribute] Attribute `is_polynomial` is not defined on `Basic` in union `Unknown | Basic`
- sympy/solvers/solvers.py:3262:38: error[unsupported-operator] Operator `**` is not supported between objects of type `Basic | Divergent | Divergent` and `Literal[2]`
+ sympy/solvers/solvers.py:3262:38: error[unsupported-operator] Operator `**` is not supported between objects of type `Basic` and `Literal[2]`
- sympy/solvers/solvers.py:3262:45: error[unsupported-operator] Operator `**` is not supported between objects of type `Basic | Divergent | Divergent` and `Literal[2]`
+ sympy/solvers/solvers.py:3262:45: error[unsupported-operator] Operator `**` is not supported between objects of type `Basic` and `Literal[2]`
- sympy/solvers/solvers.py:3278:35: error[unresolved-attribute] Attribute `exp` is not defined on `Basic` in union `Unknown | Divergent | Basic | Divergent`
+ sympy/solvers/solvers.py:3278:35: error[unresolved-attribute] Attribute `exp` is not defined on `Basic` in union `Unknown | Basic`
- sympy/solvers/solvers.py:3278:58: error[unresolved-attribute] Attribute `exp` is not defined on `Basic` in union `Unknown | Divergent | Basic | Divergent`
+ sympy/solvers/solvers.py:3278:58: error[unresolved-attribute] Attribute `exp` is not defined on `Basic` in union `Unknown | Basic`
- sympy/solvers/solvers.py:3279:19: error[unsupported-operator] Operator `/` is not supported between objects of type `Literal[1]` and `Unknown | Divergent | Basic | Divergent`
+ sympy/solvers/solvers.py:3279:19: error[unsupported-operator] Operator `/` is not supported between objects of type `Literal[1]` and `Unknown | Basic`
- sympy/solvers/solvers.py:3280:19: error[unsupported-operator] Operator `/` is not supported between objects of type `Literal[1]` and `(Basic & ~AlwaysFalsy) | (Unknown & ~AlwaysFalsy) | Divergent`
+ sympy/solvers/solvers.py:3280:19: error[unsupported-operator] Operator `/` is not supported between objects of type `Literal[1]` and `(Basic & ~AlwaysFalsy) | (Unknown & ~AlwaysFalsy)`
- sympy/solvers/solvers.py:3291:13: error[unresolved-attribute] Attribute `exp` is not defined on `Basic` in union `Unknown | Divergent | Basic | Divergent`
+ sympy/solvers/solvers.py:3291:13: error[unresolved-attribute] Attribute `exp` is not defined on `Basic` in union `Unknown | Basic`
- sympy/solvers/solvers.py:3291:52: error[unresolved-attribute] Attribute `exp` is not defined on `Basic` in union `Unknown | Divergent | Basic | Divergent`
+ sympy/solvers/solvers.py:3291:52: error[unresolved-attribute] Attribute `exp` is not defined on `Basic` in union `Unknown | Basic`
- sympy/solvers/solvers.py:3292:42: error[unresolved-attribute] Attribute `base` is not defined on `Basic` in union `Unknown | Divergent | Basic | Divergent`
+ sympy/solvers/solvers.py:3292:42: error[unresolved-attribute] Attribute `base` is not defined on `Basic` in union `Unknown | Basic`
- sympy/solvers/solvers.py:3293:27: error[unresolved-attribute] Attribute `exp` is not defined on `Basic` in union `Unknown | Divergent | Basic | Divergent`
+ sympy/solvers/solvers.py:3293:27: error[unresolved-attribute] Attribute `exp` is not defined on `Basic` in union `Unknown | Basic`
- sympy/solvers/solvers.py:3294:19: error[unresolved-attribute] Attribute `base` is not defined on `Basic` in union `Unknown | Divergent | Basic | Divergent`
+ sympy/solvers/solvers.py:3294:19: error[unresolved-attribute] Attribute `base` is not defined on `Basic` in union `Unknown | Basic`
- Found 16494 diagnostics
+ Found 16491 diagnostics

scipy (https://github.com/scipy/scipy)
- scipy/optimize/_differentiable_functions.py:639:22: error[unresolved-attribute] Attribute `toarray` is not defined on `ndarray[tuple[Any, ...], dtype[Unknown]]` in union `Unknown | csr_array | ndarray[tuple[Any, ...], dtype[Unknown]]`
- scipy/optimize/tests/test_differentiable_functions.py:505:35: error[invalid-argument-type] Argument to function `assert_array_almost_equal` is incorrect: Expected `_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]] | int | ... omitted 5 union elements`, found `Unknown | csr_array | ndarray[tuple[Any, ...], dtype[Unknown]]`
+ scipy/optimize/tests/test_differentiable_functions.py:505:35: error[invalid-argument-type] Argument to function `assert_array_almost_equal` is incorrect: Expected `_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]] | int | ... omitted 5 union elements`, found `Unknown | csr_array`
- scipy/optimize/tests/test_differentiable_functions.py:505:45: error[invalid-argument-type] Argument to function `assert_array_almost_equal` is incorrect: Expected `_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]] | int | ... omitted 5 union elements`, found `Unknown | csr_array | ndarray[tuple[Any, ...], dtype[Unknown]]`
+ scipy/optimize/tests/test_differentiable_functions.py:505:45: error[invalid-argument-type] Argument to function `assert_array_almost_equal` is incorrect: Expected `_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]] | int | ... omitted 5 union elements`, found `Unknown | csr_array`
- scipy/optimize/tests/test_differentiable_functions.py:691:39: error[invalid-argument-type] Argument to function `assert_array_almost_equal` is incorrect: Expected `_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]] | int | ... omitted 5 union elements`, found `Unknown | csr_array | ndarray[tuple[Any, ...], dtype[Unknown]]`
+ scipy/optimize/tests/test_differentiable_functions.py:691:39: error[invalid-argument-type] Argument to function `assert_array_almost_equal` is incorrect: Expected `_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]] | int | ... omitted 5 union elements`, found `Unknown | csr_array`
- scipy/optimize/tests/test_differentiable_functions.py:691:49: error[invalid-argument-type] Argument to function `assert_array_almost_equal` is incorrect: Expected `_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]] | int | ... omitted 5 union elements`, found `Unknown | csr_array | ndarray[tuple[Any, ...], dtype[Unknown]]`
+ scipy/optimize/tests/test_differentiable_functions.py:691:49: error[invalid-argument-type] Argument to function `assert_array_almost_equal` is incorrect: Expected `_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | number[Any, int | float | complex]]]] | int | ... omitted 5 union elements`, found `Unknown | csr_array`
- scipy/spatial/transform/tests/test_rigid_transform.py:832:21: error[unsupported-operator] Operator `*` is not supported between objects of type `RigidTransform | NotImplementedType | Unknown` and `RigidTransform`
+ scipy/spatial/transform/tests/test_rigid_transform.py:832:21: error[unsupported-operator] Operator `*` is not supported between objects of type `RigidTransform | Unknown | NotImplementedType` and `RigidTransform`
- scipy/spatial/transform/tests/test_rigid_transform.py:834:21: error[unsupported-operator] Operator `*` is not supported between objects of type `RigidTransform | NotImplementedType | Unknown` and `RigidTransform`
+ scipy/spatial/transform/tests/test_rigid_transform.py:834:21: error[unsupported-operator] Operator `*` is not supported between objects of type `RigidTransform | Unknown | NotImplementedType` and `RigidTransform`
+ scipy/spatial/transform/tests/test_rigid_transform.py:835:40: error[unresolved-attribute] Attribute `as_matrix` is not defined on `NotImplementedType` in union `RigidTransform | NotImplementedType | Unknown`
- scipy/spatial/transform/tests/test_rotation.py:2501:21: error[unsupported-operator] Operator `*` is not supported between objects of type `Rotation | NotImplementedType | Unknown` and `Rotation`
+ scipy/spatial/transform/tests/test_rotation.py:2501:21: error[unsupported-operator] Operator `*` is not supported between objects of type `Rotation | Unknown | NotImplementedType` and `Rotation`
- scipy/spatial/transform/tests/test_rotation.py:2503:21: error[unsupported-operator] Operator `*` is not supported between objects of type `Rotation | NotImplementedType | Unknown` and `Rotation`
+ scipy/spatial/transform/tests/test_rotation.py:2503:21: error[unsupported-operator] Operator `*` is not supported between objects of type `Rotation | Unknown | NotImplementedType` and `Rotation`
+ scipy/spatial/transform/tests/test_rotation.py:2504:20: error[unresolved-attribute] Attribute `inv` is not defined on `NotImplementedType` in union `Rotation | NotImplementedType | Unknown`
- Found 7989 diagnostics
+ Found 7990 diagnostics

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 25, 2026

Merging this PR will improve performance by 8.29%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 25 untouched benchmarks
⏩ 30 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation hydra-zen 1.3 s 1.2 s +8.29%

Comparing mtshiba:improve-cycle-normalized (f5f3564) with main (ab37a05)

Open in CodSpeed

Footnotes

  1. 30 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 25, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-argument-type 1 0 39
invalid-await 0 40 0
unsupported-operator 6 0 13
unresolved-attribute 2 3 13
invalid-return-type 0 1 9
type-assertion-failure 0 0 10
invalid-assignment 0 0 3
not-iterable 0 0 1
Total 9 44 88

Full report with detailed diff (timing results)

mtshiba pushed a commit to mtshiba/ruff that referenced this pull request Mar 6, 2026
…m PR astral-sh#23563)

Apply the cycle_normalized simplification from astral-sh#23563:
- Replace complex match logic with iteration-count check: if iteration <= 1,
  return self directly; otherwise union previous and self
- Remove as_divergent helper (no longer used)
- Remove divergent poisoning logic in narrow.rs
- Update test expectations for improved type deduplication and ordering

This simplification fixes a duplicate list[Divergent] issue and improves
union element ordering, but does not fully resolve the sympy non-determinism.

https://claude.ai/code/session_01ASx43ig9Tdi2JYbGkiAurY
@mtshiba mtshiba force-pushed the improve-cycle-normalized branch from b1d9ada to cc269b5 Compare March 9, 2026 11:39
@mtshiba mtshiba changed the title [ty] [experiment] improve Type::cycle_normalized [ty] prevent "tainted" unions in cycle normalization Mar 9, 2026
@mtshiba mtshiba marked this pull request as ready for review March 9, 2026 12:30
@mtshiba mtshiba assigned carljm and unassigned sharkdp Mar 9, 2026
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Very nice! Makes a lot of sense. I do wonder if there could be more complex cycles where we want to skip unioning for more than two iterations -- but it's easy to bump the iteration count limit here if we need to. And as long as we start unioning at some point, it should still serve the purpose of avoiding indefinite oscillations.

@carljm carljm merged commit fd9568a into astral-sh:main Mar 10, 2026
51 checks passed
@mtshiba mtshiba deleted the improve-cycle-normalized branch March 10, 2026 01:11
@MichaReiser
Copy link
Member

I do wonder if there could be more complex cycles where we want to skip unioning for more than two iterations

One thing we always need to keep in mind is that the iteration count is global for the entire cycle and not the cycle participant. Meaning, cyclic queries only conditionally participating in a larger outer cycle (e.g. only in later iterations) may never hit the iteration () < 1 case.

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.

4 participants