Skip to content

Comments

[ty] improve complex TDD-based narrowing#23201

Open
mtshiba wants to merge 75 commits intoastral-sh:mainfrom
mtshiba:improve-23109
Open

[ty] improve complex TDD-based narrowing#23201
mtshiba wants to merge 75 commits intoastral-sh:mainfrom
mtshiba:improve-23109

Conversation

@mtshiba
Copy link
Collaborator

@mtshiba mtshiba commented Feb 10, 2026

Summary

An unsolved issue in #23109 is that the following narrowing doesn't work properly:

def _(x: int | None):
    if 1 + 1 == 2:
        if x is None:
            return

    reveal_type(x)  # revealed: int

This was attempted to be fixed in ada1084, but was abandoned due to the exponential blowup (5fd9a9c).
I've come up with a different approach to this, so I'll try it out to see if it works.

What this PR does is simple: when merging bindings, it "gates" narrowing constraints with reachability constraints.
This allows us to exclude types from unreachable paths.
The problem is that this increases the size of the TDD used for narrowing, which causes serious performance degradation.
This PR also implements optimizations to prevent this.
In order of importance:

  • narrow_by_constraint cache: Without it, CI would be so slow that it would not end (989268d).
  • Making two-element intersection a tracked function (50c976c): This seems to improve the performance of pydantic!
  • Fast path for intersection type redundancy check (5c321a0)
  • Improve NarrowingConstraint structure: intersection_disjunct now has multiple types (Conjunctions), and intersection construction is now delayed (a1e303e).
  • Remove all_negative_narrowing_constraints_for_expression: all_narrowing_constraints_for_expression now calculates both positive and negative values ​​simultaneously (8468a9e).
  • Improve constant calculation in build_predicate: This did not seem to have much effect on this PR.
    ...

ecosystem-analyzer timing results showed a significant regression in egglog-python that was missed by codspeed. Each commit gradually mitigates this regression.

commit content Timing URL
c6ad1e8 [ty] improve #23109 TDD-based narrowing https://479ba5ef.ty-ecosystem-ext.pages.dev/timing
989268d cache narrow_by_constraint_inner https://4bedca41.ty-ecosystem-ext.pages.dev/timing
8468a9e remove all_negative_narrowing_constraints_for_... https://e1404865.ty-ecosystem-ext.pages.dev/timing
a1e303e NarrowingConstraint has Cunjunctions https://b590f6ab.ty-ecosystem-ext.pages.dev/timing
50c976c cache two types intersection as a tracked function (take 2) https://21a206a0.ty-ecosystem-ext.pages.dev/timing
5c321a0 add fast path for intersection type redundancy check https://5bd0c50b.ty-ecosystem-ext.pages.dev/timing
9363927 avoid expensive intersection type checks https://7f852abb.ty-ecosystem-ext.pages.dev/timing

Test Plan

mdtest updated

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

astral-sh-bot bot commented Feb 10, 2026

Typing conformance results

No changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 10, 2026

Memory usage report

Summary

Project Old New Diff Outcome
prefect 700.72MB 719.20MB +2.64% (18.48MB)
sphinx 272.09MB 279.27MB +2.64% (7.18MB)
trio 119.36MB 122.70MB +2.80% (3.34MB)
flake8 49.46MB 50.93MB +2.98% (1.48MB)

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
semantic_index 189.71MB 207.51MB +9.38% (17.79MB)
all_negative_narrowing_constraints_for_expression 2.32MB 0.00B -100.00% (2.32MB)
IntersectionType<'db>::from_two_elements_ 0.00B 780.69kB +780.69kB (new)
all_narrowing_constraints_for_expression 5.64MB 4.92MB -12.70% (733.16kB)
NarrowingConstraint 0.00B 709.63kB +709.63kB (new)
infer_expression_types_impl 54.94MB 55.53MB +1.09% (611.55kB)
IntersectionType<'db>::from_two_elements_::interned_arguments 0.00B 521.12kB +521.12kB (new)
DualNarrowingConstraints 0.00B 391.66kB +391.66kB (new)
infer_definition_types 86.91MB 87.24MB +0.38% (334.77kB)
infer_expression_type_impl 13.77MB 14.08MB +2.25% (317.15kB)
infer_scope_types_impl 53.63MB 53.71MB +0.15% (80.95kB)
StaticClassLiteral<'db>::implicit_attribute_inner_ 9.71MB 9.75MB +0.42% (41.64kB)
Type<'db>::member_lookup_with_policy_ 14.87MB 14.90MB +0.20% (30.38kB)
is_redundant_with_impl 5.65MB 5.62MB -0.52% (29.99kB)
is_redundant_with_impl::interned_arguments 5.63MB 5.60MB -0.39% (22.60kB)
... 37 more

sphinx

Name Old New Diff Outcome
semantic_index 69.45MB 75.63MB +8.89% (6.17MB)
all_negative_narrowing_constraints_for_expression 840.16kB 0.00B -100.00% (840.16kB)
NarrowingConstraint 0.00B 651.81kB +651.81kB (new)
IntersectionType<'db>::from_two_elements_ 0.00B 569.89kB +569.89kB (new)
IntersectionType<'db>::from_two_elements_::interned_arguments 0.00B 308.52kB +308.52kB (new)
DualNarrowingConstraints 0.00B 274.71kB +274.71kB (new)
all_narrowing_constraints_for_expression 1.82MB 1.60MB -12.10% (225.13kB)
infer_expression_type_impl 3.42MB 3.58MB +4.67% (163.39kB)
infer_expression_types_impl 22.05MB 22.17MB +0.58% (129.91kB)
IntersectionType 1.03MB 954.43kB -9.85% (104.34kB)
infer_definition_types 24.48MB 24.54MB +0.24% (60.85kB)
infer_scope_types_impl 15.82MB 15.87MB +0.32% (51.55kB)
is_redundant_with_impl 1.86MB 1.84MB -1.06% (20.21kB)
is_redundant_with_impl::interned_arguments 2.16MB 2.14MB -0.86% (18.99kB)
Type<'db>::member_lookup_with_policy_ 6.10MB 6.11MB +0.13% (8.18kB)
... 32 more

trio

Name Old New Diff Outcome
semantic_index 33.08MB 36.04MB +8.95% (2.96MB)
NarrowingConstraint 0.00B 166.55kB +166.55kB (new)
IntersectionType<'db>::from_two_elements_ 0.00B 158.09kB +158.09kB (new)
all_negative_narrowing_constraints_for_expression 147.69kB 0.00B -100.00% (147.69kB)
IntersectionType<'db>::from_two_elements_::interned_arguments 0.00B 104.16kB +104.16kB (new)
DualNarrowingConstraints 0.00B 79.64kB +79.64kB (new)
all_narrowing_constraints_for_expression 485.46kB 412.62kB -15.00% (72.84kB)
infer_expression_type_impl 1.29MB 1.34MB +4.05% (53.42kB)
infer_expression_types_impl 6.10MB 6.12MB +0.38% (23.44kB)
infer_definition_types 7.59MB 7.61MB +0.25% (19.41kB)
is_redundant_with_impl 487.48kB 478.92kB -1.75% (8.55kB)
is_redundant_with_impl::interned_arguments 567.10kB 559.37kB -1.36% (7.73kB)
infer_scope_types_impl 5.01MB 5.01MB +0.11% (5.54kB)
UnionType 338.92kB 335.98kB -0.87% (2.94kB)
Type<'db>::try_call_dunder_get_ 1.52MB 1.52MB +0.14% (2.20kB)
... 34 more

flake8

Name Old New Diff Outcome
semantic_index 15.29MB 16.68MB +9.13% (1.40MB)
all_negative_narrowing_constraints_for_expression 35.98kB 0.00B -100.00% (35.98kB)
IntersectionType<'db>::from_two_elements_ 0.00B 34.40kB +34.40kB (new)
IntersectionType<'db>::from_two_elements_::interned_arguments 0.00B 28.70kB +28.70kB (new)
NarrowingConstraint 0.00B 27.61kB +27.61kB (new)
DualNarrowingConstraints 0.00B 18.19kB +18.19kB (new)
infer_expression_types_impl 1.08MB 1.09MB +0.90% (9.89kB)
all_narrowing_constraints_for_expression 66.12kB 57.21kB -13.46% (8.90kB)
infer_definition_types 1.89MB 1.90MB +0.27% (5.20kB)
infer_expression_type_impl 170.30kB 174.22kB +2.30% (3.92kB)
IntersectionType 90.02kB 91.12kB +1.21% (1.09kB)
is_redundant_with_impl::interned_arguments 166.20kB 165.26kB -0.57% (968.00B)
is_redundant_with_impl 158.98kB 158.23kB -0.47% (768.00B)
UnionType 112.44kB 111.89kB -0.49% (560.00B)
for_constraint_pair_inner 14.38kB 13.89kB -3.42% (504.00B)
... 10 more

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 10, 2026

Merging this PR will improve performance by 24.57%

⚡ 1 improved benchmark
✅ 53 untouched benchmarks
🆕 1 new benchmark

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime pydantic 7.5 s 6.1 s +24.57%
🆕 Simulation ty_micro[large_union_narrowing] N/A 293.9 ms N/A

Comparing mtshiba:improve-23109 (f251ccb) with main (66defe9)

Open in CodSpeed

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 10, 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/cmd/style.py:697:27: error[unresolved-attribute] Attribute `lineno` is not defined on `AST & ~Str` in union `Str | (AST & ~Str)`
- lib/spack/spack/cmd/style.py:697:40: error[unresolved-attribute] Attribute `col_offset` is not defined on `AST & ~Str` in union `Str | (AST & ~Str)`
- 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[str | Unknown | int | ... omitted 3 union elements]`
- lib/spack/spack/package_base.py:252:33: error[unresolved-attribute] Object of type `(Self@__init__ & <Protocol with members 'executables'> & ~<Protocol with members 'libraries'>) | (Self@__init__ & <Protocol with members 'libraries'> & ~<Protocol with members 'executables'>)` has no attribute `namespace`
+ lib/spack/spack/package_base.py:252:33: error[unresolved-attribute] Object of type `(Self@__init__ & <Protocol with members 'libraries'> & ~<Protocol with members 'executables'>) | (Self@__init__ & <Protocol with members 'executables'> & ~<Protocol with members 'libraries'>)` has no attribute `namespace`
- lib/spack/spack/package_base.py:252:55: error[unresolved-attribute] Object of type `(Self@__init__ & <Protocol with members 'executables'> & ~<Protocol with members 'libraries'>) | (Self@__init__ & <Protocol with members 'libraries'> & ~<Protocol with members 'executables'>)` has no attribute `name`
+ lib/spack/spack/package_base.py:252:55: error[unresolved-attribute] Object of type `(Self@__init__ & <Protocol with members 'libraries'> & ~<Protocol with members 'executables'>) | (Self@__init__ & <Protocol with members 'executables'> & ~<Protocol with members 'libraries'>)` has no attribute `name`
- lib/spack/spack/package_base.py:265:48: error[unresolved-attribute] Object of type `(Self@__init__ & <Protocol with members 'executables'> & ~<Protocol with members 'libraries'> & ~<Protocol with members 'determine_version'>) | (Self@__init__ & <Protocol with members 'libraries'> & ~<Protocol with members 'executables'> & ~<Protocol with members 'determine_version'>)` has no attribute `name`
+ lib/spack/spack/package_base.py:265:48: error[unresolved-attribute] Object of type `(Self@__init__ & <Protocol with members 'libraries'> & ~<Protocol with members 'executables'> & ~<Protocol with members 'determine_version'>) | (Self@__init__ & <Protocol with members 'executables'> & ~<Protocol with members 'libraries'> & ~<Protocol with members 'determine_version'>)` has no attribute `name`
- lib/spack/spack/package_base.py:265:58: error[unresolved-attribute] Object of type `(Self@__init__ & <Protocol with members 'executables'> & ~<Protocol with members 'libraries'> & ~<Protocol with members 'determine_version'>) | (Self@__init__ & <Protocol with members 'libraries'> & ~<Protocol with members 'executables'> & ~<Protocol with members 'determine_version'>)` has no attribute `namespace`
+ lib/spack/spack/package_base.py:265:58: error[unresolved-attribute] Object of type `(Self@__init__ & <Protocol with members 'libraries'> & ~<Protocol with members 'executables'> & ~<Protocol with members 'determine_version'>) | (Self@__init__ & <Protocol with members 'executables'> & ~<Protocol with members 'libraries'> & ~<Protocol with members 'determine_version'>)` has no attribute `namespace`
- lib/spack/spack/vendor/ruamel/yaml/emitter.py:806:26: error[unresolved-attribute] Attribute `empty` is not defined on `None` in union `Unknown | None`
+ lib/spack/spack/vendor/ruamel/yaml/emitter.py:806:26: error[unresolved-attribute] Attribute `empty` is not defined on `None` in union `None | Unknown`
- lib/spack/spack/vendor/ruamel/yaml/emitter.py:807:25: error[unresolved-attribute] Attribute `multiline` is not defined on `None` in union `Unknown | None`
+ lib/spack/spack/vendor/ruamel/yaml/emitter.py:807:25: error[unresolved-attribute] Attribute `multiline` is not defined on `None` in union `None | Unknown`
- Found 4387 diagnostics
+ Found 4385 diagnostics

websockets (https://github.com/aaugustin/websockets)
- src/websockets/asyncio/connection.py:1219:17: error[unresolved-reference] Name `exceptions` used when not defined
- src/websockets/asyncio/connection.py:1235:17: error[unresolved-reference] Name `exceptions` used when not defined
- src/websockets/asyncio/connection.py:1242:29: error[unresolved-reference] Name `exceptions` used when not defined
- src/websockets/asyncio/connection.py:1243:15: error[unresolved-reference] Name `ExceptionGroup` used when not defined
- src/websockets/asyncio/connection.py:1243:51: error[unresolved-reference] Name `exceptions` used when not defined
- src/websockets/legacy/protocol.py:1610:17: error[unresolved-reference] Name `exceptions` used when not defined
- src/websockets/legacy/protocol.py:1623:17: error[unresolved-reference] Name `exceptions` used when not defined
- src/websockets/legacy/protocol.py:1630:29: error[unresolved-reference] Name `exceptions` used when not defined
- src/websockets/legacy/protocol.py:1631:15: error[unresolved-reference] Name `ExceptionGroup` used when not defined
- src/websockets/legacy/protocol.py:1631:51: error[unresolved-reference] Name `exceptions` used when not defined
- Found 44 diagnostics
+ Found 34 diagnostics

aiortc (https://github.com/aiortc/aiortc)
- src/aiortc/sdp.py:446:52: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `None | str | Unknown`
+ src/aiortc/sdp.py:446:52: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `None | Unknown | str`

graphql-core (https://github.com/graphql-python/graphql-core)
- src/graphql/language/visitor.py:277:26: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `tuple[int | str, Node]`, found `tuple[None | Any | int | Node, Node | (Any & tuple[object, ...] & ~Node) | (tuple[Unknown, ...] & ~Node)]`
+ src/graphql/language/visitor.py:277:26: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `tuple[int | str, Node]`, found `tuple[None | Any | int | Node, Node | (Any & tuple[object, ...]) | tuple[Unknown, ...]]`

kopf (https://github.com/nolar/kopf)
- kopf/_cogs/structs/references.py:306:24: error[unresolved-attribute] Attribute `split` is not defined on `Marker`, `(Resource, /) -> bool`, `None` in union `str | Marker | ((Resource, /) -> bool) | None`
- kopf/_cogs/structs/references.py:307:55: error[unresolved-attribute] Attribute `split` is not defined on `Marker`, `(Resource, /) -> bool`, `None` in union `str | Marker | ((Resource, /) -> bool) | None`
- kopf/_cogs/structs/references.py:308:53: error[unresolved-attribute] Attribute `split` is not defined on `Marker`, `(Resource, /) -> bool`, `None` in union `str | Marker | ((Resource, /) -> bool) | None`
- kopf/_cogs/structs/references.py:309:54: error[unresolved-attribute] Attribute `split` is not defined on `Marker`, `(Resource, /) -> bool`, `None` in union `str | Marker | ((Resource, /) -> bool) | None`
+ kopf/_cogs/structs/references.py:306:24: error[unresolved-attribute] Attribute `split` is not defined on `(Resource, /) -> bool`, `Marker`, `None` in union `(str & Top[(...) -> object]) | ((Resource, /) -> bool) | (str & ~Top[(...) -> object]) | Marker | None`
+ kopf/_cogs/structs/references.py:307:55: error[unresolved-attribute] Attribute `split` is not defined on `(Resource, /) -> bool`, `Marker`, `None` in union `(str & Top[(...) -> object]) | ((Resource, /) -> bool) | (str & ~Top[(...) -> object]) | Marker | None`
+ kopf/_cogs/structs/references.py:308:53: error[unresolved-attribute] Attribute `split` is not defined on `(Resource, /) -> bool`, `Marker`, `None` in union `(str & Top[(...) -> object]) | ((Resource, /) -> bool) | (str & ~Top[(...) -> object]) | Marker | None`
+ kopf/_cogs/structs/references.py:309:54: error[unresolved-attribute] Attribute `split` is not defined on `(Resource, /) -> bool`, `Marker`, `None` in union `(str & Top[(...) -> object]) | ((Resource, /) -> bool) | (str & ~Top[(...) -> object]) | Marker | None`
- kopf/_cogs/structs/references.py:310:45: error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["."]` and `str | Marker | ((Resource, /) -> bool) | None`
+ kopf/_cogs/structs/references.py:310:45: error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["."]` and `(str & Top[(...) -> object]) | ((Resource, /) -> bool) | (str & ~Top[(...) -> object]) | Marker | None`
- kopf/_cogs/structs/references.py:311:51: error[unresolved-attribute] Attribute `split` is not defined on `Marker`, `(Resource, /) -> bool`, `None` in union `str | Marker | ((Resource, /) -> bool) | None`
- kopf/_cogs/structs/references.py:312:54: error[unresolved-attribute] Attribute `split` is not defined on `Marker`, `(Resource, /) -> bool`, `None` in union `str | Marker | ((Resource, /) -> bool) | None`
+ kopf/_cogs/structs/references.py:311:51: error[unresolved-attribute] Attribute `split` is not defined on `(Resource, /) -> bool`, `Marker`, `None` in union `(str & Top[(...) -> object]) | ((Resource, /) -> bool) | (str & ~Top[(...) -> object]) | Marker | None`
+ kopf/_cogs/structs/references.py:312:54: error[unresolved-attribute] Attribute `split` is not defined on `(Resource, /) -> bool`, `Marker`, `None` in union `(str & Top[(...) -> object]) | ((Resource, /) -> bool) | (str & ~Top[(...) -> object]) | Marker | None`
- kopf/_cogs/structs/references.py:315:42: error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["/"]` and `str | Marker | ((Resource, /) -> bool) | None`
+ kopf/_cogs/structs/references.py:315:42: error[unsupported-operator] Operator `in` is not supported between objects of type `Literal["/"]` and `(str & Top[(...) -> object]) | ((Resource, /) -> bool) | (str & ~Top[(...) -> object]) | Marker | None`
- kopf/_cogs/structs/references.py:316:51: error[unresolved-attribute] Attribute `rsplit` is not defined on `Marker`, `(Resource, /) -> bool`, `None` in union `str | Marker | ((Resource, /) -> bool) | None`
- kopf/_cogs/structs/references.py:317:53: error[unresolved-attribute] Attribute `rsplit` is not defined on `Marker`, `(Resource, /) -> bool`, `None` in union `str | Marker | ((Resource, /) -> bool) | None`
+ kopf/_cogs/structs/references.py:316:51: error[unresolved-attribute] Attribute `rsplit` is not defined on `(Resource, /) -> bool`, `Marker`, `None` in union `(str & Top[(...) -> object]) | ((Resource, /) -> bool) | (str & ~Top[(...) -> object]) | Marker | None`
+ kopf/_cogs/structs/references.py:317:53: error[unresolved-attribute] Attribute `rsplit` is not defined on `(Resource, /) -> bool`, `Marker`, `None` in union `(str & Top[(...) -> object]) | ((Resource, /) -> bool) | (str & ~Top[(...) -> object]) | Marker | None`

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

porcupine (https://github.com/Akuli/porcupine)
- porcupine/pluginmanager.py:133:49: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Never]`, found `Unknown | str`
- Found 25 diagnostics
+ Found 24 diagnostics

ignite (https://github.com/pytorch/ignite)
+ ignite/engine/deterministic.py:270:37: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- tests/ignite/distributed/utils/__init__.py:154:10: error[unsupported-operator] Operator `in` is not supported between objects of type `None | str` and `Literal["xla-tpu"]`
+ tests/ignite/distributed/utils/__init__.py:154:10: error[unsupported-operator] Operator `in` is not supported between objects of type `str | None` and `Literal["xla-tpu"]`
- tests/ignite/distributed/utils/__init__.py:157:10: error[unsupported-operator] Operator `in` is not supported between objects of type `None | str` and `Literal["horovod"]`
+ tests/ignite/distributed/utils/__init__.py:157:10: error[unsupported-operator] Operator `in` is not supported between objects of type `str | None` and `Literal["horovod"]`
- tests/ignite/distributed/utils/__init__.py:286:10: error[unsupported-operator] Operator `in` is not supported between objects of type `None | str` and `Literal["xla-tpu"]`
+ tests/ignite/distributed/utils/__init__.py:286:10: error[unsupported-operator] Operator `in` is not supported between objects of type `str | None` and `Literal["xla-tpu"]`
- Found 2142 diagnostics
+ Found 2143 diagnostics

pylint (https://github.com/pycqa/pylint)
- pylint/checkers/async_checker.py:92:63: error[unresolved-attribute] Attribute `name` is not defined on `None` in union `(Unknown & ~AlwaysTruthy) | (Unknown & ~AlwaysFalsy) | None`
- Found 220 diagnostics
+ Found 219 diagnostics

pylox (https://github.com/sco1/pylox)
- 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]`
+ 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]`

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, Unknown | str]]`
+ 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: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: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: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: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:20: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]]`

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[str | Unknown | None]`
+ 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]`

pydantic (https://github.com/pydantic/pydantic)
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `CustomErrorSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `DecimalSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `StringSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `BytesSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `DateSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `TimeSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `DatetimeSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `TimedeltaSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `LiteralSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `MissingSentinelSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `EnumSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `IsInstanceSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `IsSubclassSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `CallableSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `ListSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `TupleSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `SetSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `FrozenSetSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `GeneratorSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `DictSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `AfterValidatorFunctionSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `BeforeValidatorFunctionSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `WrapValidatorFunctionSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `PlainValidatorFunctionSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `FloatSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `NullableSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `UnionSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `TaggedUnionSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `ChainSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `LaxOrStrictSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `JsonOrPythonSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `TypedDictSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `ModelFieldsSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `ModelSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `DataclassArgsSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `DataclassSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `ArgumentsSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `ArgumentsV3Schema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `CallSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `InvalidSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `JsonSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `UrlSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `MultiHostUrlSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `DefinitionsSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `UuidSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `ComplexSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `AnySchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `NoneSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `BoolSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `IntSchema`: Unknown key "schema_ref"
- pydantic/_internal/_generate_schema.py:2814:37: error[invalid-key] Unknown key "schema_ref" for TypedDict `WithDefaultSchema`: Unknown key "schema_ref"
- Found 3201 diagnostics
+ Found 3150 diagnostics

mitmproxy (https://github.com/mitmproxy/mitmproxy)
- mitmproxy/addons/cut.py:57:24: error[unresolved-attribute] Attribute `headers` is not defined on `Flow & ~AlwaysFalsy` in union `(Flow & ~AlwaysFalsy) | (Any & ~AlwaysFalsy)`
+ mitmproxy/addons/cut.py:57:24: error[unresolved-attribute] Attribute `headers` is not defined on `Flow & ~AlwaysFalsy` in union `(Flow & ~AlwaysFalsy) | (Any & Top[list[Unknown]] & ~AlwaysFalsy) | (Any & Cert & ~AlwaysFalsy) | ... omitted 3 union elements`

urllib3 (https://github.com/urllib3/urllib3)
- src/urllib3/http2/connection.py:263:21: warning[possibly-unresolved-reference] Name `headers` used when possibly not defined
- Found 279 diagnostics
+ Found 278 diagnostics

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

meson (https://github.com/mesonbuild/meson)
- mesonbuild/interpreter/interpreter.py:2796:56: error[invalid-argument-type] Argument to function `bold` is incorrect: Expected `str`, found `(str & ~AlwaysTruthy & ~AlwaysFalsy) | (Program & ~AlwaysTruthy & ~AlwaysFalsy) | (Unknown & ~AlwaysFalsy)`
+ mesonbuild/interpreter/interpreter.py:2796:56: error[invalid-argument-type] Argument to function `bold` is incorrect: Expected `str`, found `(str & ~AlwaysFalsy & ~AlwaysTruthy) | (Program & ~AlwaysTruthy & ~AlwaysFalsy) | (Unknown & ~AlwaysFalsy)`
- mesonbuild/interpreter/interpreter.py:2797:27: error[invalid-argument-type] Argument to function `open` is incorrect: Expected `int | str | bytes | PathLike[str] | PathLike[bytes]`, found `(str & ~AlwaysTruthy & ~AlwaysFalsy) | (Program & ~AlwaysTruthy & ~AlwaysFalsy) | (Unknown & ~AlwaysFalsy)`
+ mesonbuild/interpreter/interpreter.py:2797:27: error[invalid-argument-type] Argument to function `open` is incorrect: Expected `int | str | bytes | PathLike[str] | PathLike[bytes]`, found `(str & ~AlwaysFalsy & ~AlwaysTruthy) | (Program & ~AlwaysTruthy & ~AlwaysFalsy) | (Unknown & ~AlwaysFalsy)`

cwltool (https://github.com/common-workflow-language/cwltool)
- cwltool/main.py:301:42: error[invalid-argument-type] Argument to function `realize_input_schema` is incorrect: Expected `MutableSequence[str | MutableMapping[str, None | int | str | ... omitted 3 union elements]]`, found `list[str | MutableMapping[str, None | int | str | ... omitted 3 union elements] | (Unknown & Top[Mapping[Unknown, object]]) | ... omitted 4 union elements]`
+ cwltool/main.py:301:42: error[invalid-argument-type] Argument to function `realize_input_schema` is incorrect: Expected `MutableSequence[str | MutableMapping[str, None | int | str | ... omitted 3 union elements]]`, found `list[str | MutableMapping[str, None | int | str | ... omitted 3 union elements] | (int & Top[Mapping[Unknown, object]]) | ... omitted 4 union elements]`

trio (https://github.com/python-trio/trio)
- src/trio/_ssl.py:638:16: warning[possibly-unresolved-reference] Name `ret` used when possibly not defined
- Found 473 diagnostics
+ Found 472 diagnostics

openlibrary (https://github.com/internetarchive/openlibrary)
- openlibrary/catalog/utils/__init__.py:132:17: error[unresolved-attribute] Attribute `search` is not defined on `str` in union `Unknown | str`
+ openlibrary/catalog/utils/__init__.py:132:17: error[unresolved-attribute] Attribute `search` is not defined on `str` in union `str | Unknown`

manticore (https://github.com/trailofbits/manticore)
- manticore/core/plugin.py:329:32: error[invalid-argument-type] Argument to bound method `add` is incorrect: Argument type `PstatsFormatted` does not satisfy upper bound `Stats` of type variable `Self`
- manticore/core/plugin.py:329:32: error[invalid-argument-type] Argument to bound method `add` is incorrect: Expected `None | str | profile.Profile | cProfile.Profile | Stats`, found `PstatsFormatted`
- Found 11085 diagnostics
+ Found 11083 diagnostics

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/structured_configs/_implementations.py:2555:76: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 516 diagnostics
+ Found 515 diagnostics

setuptools (https://github.com/pypa/setuptools)
- setuptools/_vendor/backports/tarfile/__init__.py:2713:20: error[unresolved-attribute] Attribute `offset` is not defined on `None` in union `Unknown | None`
+ setuptools/_vendor/backports/tarfile/__init__.py:2713:20: error[unresolved-attribute] Attribute `offset` is not defined on `None` in union `(Unknown & ~None) | None`

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/deployments/flow_runs.py:141:59: error[invalid-argument-type] Argument to bound method `read_deployment_by_name` is incorrect: Expected `str`, found `str | UUID`
+ src/prefect/deployments/flow_runs.py:141:59: error[invalid-argument-type] Argument to bound method `read_deployment_by_name` is incorrect: Expected `str`, found `UUID | str`
- src/prefect/deployments/flow_runs.py:338:62: error[invalid-argument-type] Argument to bound method `read_deployment_by_name` is incorrect: Expected `str`, found `str | UUID`
+ src/prefect/deployments/flow_runs.py:338:62: error[invalid-argument-type] Argument to bound method `read_deployment_by_name` is incorrect: Expected `str`, found `UUID | str`
- src/prefect/deployments/runner.py:1017:70: error[unresolved-attribute] Attribute `__name__` is not defined on `((...) -> Any) & ((*args: object, **kwargs: object) -> object)` in union `Unknown | (((...) -> Any) & ((*args: object, **kwargs: object) -> object))`
+ src/prefect/deployments/runner.py:1017:70: error[unresolved-attribute] Attribute `__name__` is not defined on `(...) -> Any` in union `Unknown | ((...) -> Any)`
+ src/prefect/flow_engine.py:1004:32: error[invalid-await] `Unknown | R@FlowRunEngine | Coroutine[Any, Any, R@FlowRunEngine]` is not awaitable
+ src/prefect/flow_engine.py:1610:24: error[invalid-await] `Unknown | R@AsyncFlowRunEngine | Coroutine[Any, Any, R@AsyncFlowRunEngine]` is not awaitable
- src/prefect/flows.py:286:34: error[unresolved-attribute] Object of type `((**P@Flow) -> R@Flow) & ((*args: object, **kwargs: object) -> object)` has no attribute `__name__`
+ src/prefect/flows.py:286:34: error[unresolved-attribute] Object of type `(**P@Flow) -> R@Flow` has no attribute `__name__`
- src/prefect/flows.py:404:68: error[unresolved-attribute] Object of type `((**P@Flow) -> R@Flow) & ((*args: object, **kwargs: object) -> object)` has no attribute `__name__`
+ src/prefect/flows.py:404:68: error[unresolved-attribute] Object of type `(**P@Flow) -> R@Flow` has no attribute `__name__`
- src/prefect/utilities/templating.py:216:36: error[invalid-assignment] Object of type `str | Unknown` is not assignable to `T@apply_values`
+ src/prefect/utilities/templating.py:216:36: error[invalid-assignment] Object of type `str` is not assignable to `T@apply_values`
- src/prefect/utilities/templating.py:216:36: error[no-matching-overload] No overload of bound method `replace` matches arguments
- src/prefect/utilities/templating.py:216:36: warning[possibly-missing-attribute] Attribute `replace` may be missing on object of type `str | T@apply_values`

pycryptodome (https://github.com/Legrandin/pycryptodome)
- lib/Crypto/SelfTest/loader.py:100:13: error[unresolved-attribute] Attribute `others` is not defined on `None` in union `None | TestVector`
- lib/Crypto/Util/asn1.py:1032:16: error[unsupported-operator] Operator `<` is not supported between objects of type `Literal[-1] | Unknown | None` and `Literal[0]`
- Found 1338 diagnostics
+ Found 1336 diagnostics

egglog-python (https://github.com/egraphs-good/egglog-python)
- python/egglog/egraph.py:1959:24: error[invalid-argument-type] Argument to function `expr_action` is incorrect: Expected `BaseExpr`, found `(BaseExpr & ~Action) | (Fact & ~Action)`
- Found 1460 diagnostics
+ Found 1459 diagnostics

django-stubs (https://github.com/typeddjango/django-stubs)
- mypy_django_plugin/django/context.py:328:64: error[unresolved-attribute] Attribute `base_field` is not defined on `Field[Any, Any] & ArrayField`, `ForeignObjectRel & ArrayField` in union `(Field[Any, Any] & Top[django.contrib.postgres.fields.array.ArrayField[Unknown, Unknown]]) | (ForeignObjectRel & Top[django.contrib.postgres.fields.array.ArrayField[Unknown, Unknown]]) | (Field[Any, Any] & mypy_django_plugin.django.context.ArrayField) | (ForeignObjectRel & mypy_django_plugin.django.context.ArrayField)`
+ mypy_django_plugin/django/context.py:328:64: error[unresolved-attribute] Attribute `base_field` is not defined on `Field[Any, Any] & ArrayField`, `ForeignObjectRel & ArrayField`, `Field[Unknown, Unknown] & ArrayField` in union `(Field[Any, Any] & Top[django.contrib.postgres.fields.array.ArrayField[Unknown, Unknown]]) | (ForeignObjectRel & Top[django.contrib.postgres.fields.array.ArrayField[Unknown, Unknown]]) | (Field[Any, Any] & mypy_django_plugin.django.context.ArrayField) | ... omitted 3 union elements`

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/vendor/ply/lex.py:924:9: error[unresolved-attribute] Attribute `info` is not defined on `None` in union `Unknown | None | PlyLogger`
+ ddtrace/vendor/ply/lex.py:924:9: error[unresolved-attribute] Attribute `info` is not defined on `None` in union `None | (Unknown & ~None) | PlyLogger`
- ddtrace/vendor/ply/lex.py:925:9: error[unresolved-attribute] Attribute `info` is not defined on `None` in union `Unknown | None | PlyLogger`
+ ddtrace/vendor/ply/lex.py:925:9: error[unresolved-attribute] Attribute `info` is not defined on `None` in union `None | (Unknown & ~None) | PlyLogger`
- ddtrace/vendor/ply/lex.py:926:9: error[unresolved-attribute] Attribute `info` is not defined on `None` in union `Unknown | None | PlyLogger`
+ ddtrace/vendor/ply/lex.py:926:9: error[unresolved-attribute] Attribute `info` is not defined on `None` in union `None | (Unknown & ~None) | PlyLogger`
- ddtrace/vendor/ply/lex.py:953:17: error[unresolved-attribute] Attribute `info` is not defined on `None` in union `Unknown | None | PlyLogger`
+ ddtrace/vendor/ply/lex.py:953:17: error[unresolved-attribute] Attribute `info` is not defined on `None` in union `None | (Unknown & ~None) | PlyLogger`
- ddtrace/vendor/ply/lex.py:959:17: error[unresolved-attribute] Attribute `info` is not defined on `None` in union `Unknown | None | PlyLogger`
+ ddtrace/vendor/ply/lex.py:959:17: error[unresolved-attribute] Attribute `info` is not defined on `None` in union `None | (Unknown & ~None) | PlyLogger`
- ddtrace/vendor/ply/lex.py:966:9: error[unresolved-attribute] Attribute `info` is not defined on `None` in union `Unknown | None | PlyLogger`
+ ddtrace/vendor/ply/lex.py:966:9: error[unresolved-attribute] Attribute `info` is not defined on `None` in union `None | (Unknown & ~None) | PlyLogger`
- ddtrace/vendor/ply/lex.py:975:17: error[unresolved-attribute] Attribute `info` is not defined on `None` in union `Unknown | None | PlyLogger`
+ ddtrace/vendor/ply/lex.py:975:17: error[unresolved-attribute] Attribute `info` is not defined on `None` in union `None | (Unknown & ~None) | PlyLogger`
- scripts/freshvenvs.py:343:69: error[invalid-argument-type] Argument to function `_versions_fully_cover_bounds` is incorrect: Expected `list[str]`, found `list[Unknown | Version] & ~AlwaysFalsy`
+ scripts/freshvenvs.py:343:69: error[invalid-argument-type] Argument to function `_versions_fully_cover_bounds` is incorrect: Expected `list[str]`, found `list[Version | Unknown] & ~AlwaysFalsy`

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[Buffer | Unknown | str]`
+ ibis/selectors.py:333:16: error[invalid-return-type] Return type does not match returned value: expected `frozenset[str]`, found `frozenset[Unknown | str | Buffer]`

hydpy (https://github.com/hydpy-dev/hydpy)
- hydpy/core/devicetools.py:2429:9: error[type-assertion-failure] Type `Literal["inlets", "outlets", "observers", "receivers", "senders", "inputs", "outputs"]` is not equivalent to `Never`
+ hydpy/exe/xmltools.py:2389:16: error[invalid-return-type] Return type does not match returned value: expected `_TypeSetOrAddOrMultiplyItem@_get_changeitem`, found `SetItem | (_TypeSetOrAddOrMultiplyItem@_get_changeitem & ~SetItem)`

pandas (https://github.com/pandas-dev/pandas)
- pandas/core/arrays/categorical.py:494:25: error[unresolved-attribute] Attribute `_codes` is not defined on `RangeIndex`, `ndarray[tuple[Any, ...], dtype[Any]]`, `ExtensionArray` in union `Unknown | RangeIndex | ndarray[tuple[Any, ...], dtype[Any]] | ExtensionArray`
+ pandas/core/arrays/categorical.py:494:25: error[unresolved-attribute] Attribute `_codes` is not defined on `ExtensionArray`, `RangeIndex`, `ndarray[tuple[Any, ...], dtype[Any]]` in union `(Unknown & ~Index & ~Series & ~ExtensionArray) | (Unknown & Index) | (Unknown & Series) | ... omitted 3 union elements`
+ pandas/core/arrays/datetimes.py:2984:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[_TimestampNoneT1@_maybe_normalize_endpoints, _TimestampNoneT2@_maybe_normalize_endpoints]`, found `tuple[Timestamp | None | _TimestampNoneT1@_maybe_normalize_endpoints, Timestamp | None | _TimestampNoneT2@_maybe_normalize_endpoints]`
+ pandas/core/frame.py:4215:28: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Iterable[Unknown]`, found `Hashable & ~slice[object, object, object] & ~DataFrame`
- pandas/core/indexes/base.py:1827:16: error[invalid-return-type] Return type does not match returned value: expected `list[Hashable]`, found `(Top[list[Unknown]] & ~AlwaysFalsy) | list[Hashable] | list[Unknown | None] | list[Unknown | (Hashable & ~None)]`
+ pandas/core/indexes/base.py:1827:16: error[invalid-return-type] Return type does not match returned value: expected `list[Hashable]`, found `(Top[list[Unknown]] & ~AlwaysFalsy) | (list[Unknown | int | str] & ~AlwaysFalsy) | list[Hashable] | list[Unknown | None] | list[Unknown | (Hashable & ~None)]`
- pandas/core/tools/datetimes.py:387:23: error[unresolved-attribute] Attribute `_dt_tz_convert` is not defined on `ndarray[tuple[Any, ...], dtype[Any]] & ~Index` in union `(Unknown & ~Top[list[Unknown]] & ~tuple[object, ...] & ~NumpyExtensionArray & ~Index) | (ndarray[tuple[Any, ...], dtype[Any]] & ~Index)`
+ pandas/core/tools/datetimes.py:387:23: error[unresolved-attribute] Attribute `_dt_tz_convert` is not defined on `ndarray[tuple[Any, ...], dtype[Any]] & ~Index`, `ndarray[tuple[Any, ...], dtype[Unknown]] & ~Index` in union `(Unknown & ~Top[list[Unknown]] & ~tuple[object, ...] & ~NumpyExtensionArray & ~Index) | (ndarray[tuple[Any, ...], dtype[Any]] & ~Index) | (ndarray[tuple[Any, ...], dtype[Unknown]] & ~Index)`
- pandas/core/tools/datetimes.py:389:23: error[unresolved-attribute] Attribute `_dt_tz_localize` is not defined on `ndarray[tuple[Any, ...], dtype[Any]] & ~Index` in union `(Unknown & ~Top[list[Unknown]] & ~tuple[object, ...] & ~NumpyExtensionArray & ~Index) | (ndarray[tuple[Any, ...], dtype[Any]] & ~Index)`
+ pandas/core/tools/datetimes.py:389:23: error[unresolved-attribute] Attribute `_dt_tz_localize` is not defined on `ndarray[tuple[Any, ...], dtype[Any]] & ~Index`, `ndarray[tuple[Any, ...], dtype[Unknown]] & ~Index` in union `(Unknown & ~Top[list[Unknown]] & ~tuple[object, ...] & ~NumpyExtensionArray & ~Index) | (ndarray[tuple[Any, ...], dtype[Any]] & ~Index) | (ndarray[tuple[Any, ...], dtype[Unknown]] & ~Index)`
- pandas/core/tools/numeric.py:317:16: error[unresolved-attribute] Attribute `_constructor` is not defined on `Number & ~Timedelta & ~Timestamp`, `number[Any, int | float | complex] & ~Timedelta & ~Timestamp`, `Decimal` in union `(Unknown & Timedelta) | (Unknown & Timestamp) | (Number & ~Timedelta & ~Timestamp) | ... omitted 3 union elements`
+ pandas/core/tools/numeric.py:317:16: error[unresolved-attribute] Attribute `_constructor` is not defined on `Decimal`, `Number & ~Timedelta & ~Timestamp`, `number[Any, int | float | complex] & ~Timedelta & ~Timestamp` in union `(Unknown & Timedelta) | (Unknown & Timestamp) | (Unknown & ~Timedelta & ~Timestamp) | ... omitted 3 union elements`
- pandas/core/tools/numeric.py:317:47: error[unresolved-attribute] Attribute `index` is not defined on `Number & ~Timedelta & ~Timestamp`, `number[Any, int | float | complex] & ~Timedelta & ~Timestamp`, `Decimal` in union `(Unknown & Timedelta) | (Unknown & Timestamp) | (Number & ~Timedelta & ~Timestamp) | ... omitted 3 union elements`
+ pandas/core/tools/numeric.py:317:47: error[unresolved-attribute] Attribute `index` is not defined on `Decimal`, `Number & ~Timedelta & ~Timestamp`, `number[Any, int | float | complex] & ~Timedelta & ~Timestamp` in union `(Unknown & Timedelta) | (Unknown & Timestamp) | (Unknown & ~Timedelta & ~Timestamp) | ... omitted 3 union elements`
- pandas/core/tools/numeric.py:317:63: error[unresolved-attribute] Attribute `name` is not defined on `Number & ~Timedelta & ~Timestamp`, `number[Any, int | float | complex] & ~Timedelta & ~Timestamp`, `Decimal` in union `(Unknown & Timedelta) | (Unknown & Timestamp) | (Number & ~Timedelta & ~Timestamp) | ... omitted 3 union elements`
+ pandas/core/tools/numeric.py:317:63: error[unresolved-attribute] Attribute `name` is not defined on `Decimal`, `Number & ~Timedelta & ~Timestamp`, `number[Any, int | float | complex] & ~Timedelta & ~Timestamp` in union `(Unknown & Timedelta) | (Unknown & Timestamp) | (Unknown & ~Timedelta & ~Timestamp) | ... omitted 3 union elements`
- pandas/core/tools/numeric.py:323:35: error[unresolved-attribute] Attribute `name` is not defined on `Number & ~Timedelta & ~Timestamp`, `number[Any, int | float | complex] & ~Timedelta & ~Timestamp`, `Decimal` in union `(Unknown & Timedelta) | (Unknown & Timestamp) | (Number & ~Timedelta & ~Timestamp) | ... omitted 3 union elements`
+ pandas/core/tools/numeric.py:323:35: error[unresolved-attribute] Attribute `name` is not defined on `Decimal`, `Number & ~Timedelta & ~Timestamp`, `number[Any, int | float | complex] & ~Timedelta & ~Timestamp` in union `(Unknown & Timedelta) | (Unknown & Timestamp) | (Unknown & ~Timedelta & ~Timestamp) | ... omitted 3 union elements`
- pandas/plotting/_matplotlib/boxplot.py:338:27: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `Unknown | None | list[Unknown | None]`
+ pandas/plotting/_matplotlib/boxplot.py:338:27: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `(Unknown & ~Top[list[Unknown]] & ~tuple[object, ...]) | None | (Unknown & Top[list[Unknown]]) | (Unknown & tuple[object, ...]) | list[Unknown | None]`
- pandas/tests/tseries/holiday/test_holiday.py:285:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `BaseOffset | list[BaseOffset] | None`, found `list[BaseOffset | Unknown | None | list[BaseOffset]]`
+ pandas/tests/tseries/holiday/test_holiday.py:285:9: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `BaseOffset | list[BaseOffset] | None`, found `list[BaseOffset | Unknown | list[BaseOffset] | None]`
- pandas/tests/tseries/holiday/test_holiday.py:293:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `BaseOffset | list[BaseOffset] | None`, found `list[BaseOffset | Unknown | None | list[BaseOffset]]`
+ pandas/tests/tseries/holiday/test_holiday.py:293:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `BaseOffset | list[BaseOffset] | None`, found `list[BaseOffset | Unknown | list[BaseOffset] | None]`
- Found 4465 diagnostics
+ Found 4467 diagnostics

static-frame (https://github.com/static-frame/static-frame)
- static_frame/core/util.py:2489:63: error[not-iterable] Object of type `<Protocol with members '__iter__'> & ~date & ~datetime64[date | int | None] & ~int & ~Top[integer[Any]] & ~<Protocol with members '__len__'>` is not iterable
+ static_frame/core/util.py:2489:63: error[not-iterable] Object of type `<Protocol with members '__iter__'> & ~<Protocol with members '__len__'> & ~date & ~datetime64[date | int | None] & ~int & ~Top[integer[Any]]` is not iterable
- 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`

rotki (https://github.com/rotki/rotki)
- rotkehlchen/tests/unit/test_makerdao.py:170:9: error[invalid-argument-type] Argument is incorrect: Expected `defaultdict[Asset, defaultdict[str, Balance]]`, found `defaultdict[Asset | Unknown, defaultdict[str, Balance] | Balance | dict[Unknown | str, Unknown | Balance] | Unknown]`
+ rotkehlchen/tests/unit/test_makerdao.py:170:9: error[invalid-argument-type] Argument is incorrect: Expected `defaultdict[Asset, defaultdict[str, Balance]]`, found `defaultdict[Asset | Unknown, defaultdict[str, Balance] | Balance | Unknown | dict[Unknown | str, Unknown | Balance]]`
- rotkehlchen/tests/unit/test_makerdao.py:171:9: error[invalid-argument-type] Argument is incorrect: Expected `defaultdict[Asset, defaultdict[str, Balance]]`, found `defaultdict[Asset | Unknown, defaultdict[str, Balance] | Balance | dict[Unknown | str, Unknown | Balance] | Unknown]`
+ rotkehlchen/tests/unit/test_makerdao.py:171:9: error[invalid-argument-type] Argument is incorrect: Expected `defaultdict[Asset, defaultdict[str, Balance]]`, found `defaultdict[Asset | Unknown, defaultdict[str, Balance] | Balance | Unknown | dict[Unknown | str, Unknown | Balance]]`

sympy (https://github.com/sympy/sympy)
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
- sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic | int | float | complex | Any` is not assignable to `Expr | int | float | complex`
+ sympy/algebras/quaternion.py:132:22: error[invalid-assignment] Object of type `Basic` is not assignable to `Expr | int | float | complex`
- sympy/algebras/tests/test_quaternion.py:75:10: error[not-subscriptable] Cannot subscript object of type `T2'return@call_highest_priority` with no `__getitem__` method
- sympy/algebras/tests/test_quaternion.py:75:10: error[not-subscriptable] Cannot subscript object of type `T1'return@call_highest_priority` with no `__getitem__` method
- sympy/functions/combinatorial/factorials.py:967:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:967:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic`
- sympy/functions/combinatorial/factorials.py:968:29: error[unresolved-attribute] Attribute `is_nonnegative` is not defined on `int`, `float`, `complex` in union `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:968:47: error[unresolved-attribute] Attribute `is_integer` is not defined on `int`, `complex` in union `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:969:12: error[unresolved-attribute] Attribute `is_zero` is not defined on `int`, `float`, `complex` in union `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:972:13: error[unsupported-operator] Operator `-` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[1]`
+ sympy/functions/combinatorial/factorials.py:972:13: error[unsupported-operator] Operator `-` is not supported between objects of type `Basic` and `Literal[1]`
- sympy/functions/combinatorial/factorials.py:975:12: error[unresolved-attribute] Attribute `is_integer` is not defined on `int`, `complex` in union `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:976:16: error[unresolved-attribute] Attribute `is_negative` is not defined on `int`, `float`, `complex` in union `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:978:18: error[unresolved-attribute] Attribute `is_number` is not defined on `int`, `float`, `complex` in union `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:984:14: error[unresolved-attribute] Attribute `is_number` is not defined on `int`, `float`, `complex` in union `Basic | int | float | complex | Any`
- sympy/functions/combinatorial/factorials.py:986:26: error[unsupported-operator] Operator `+` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[1]`
+ sympy/functions/combinatorial/factorials.py:986:26: error[unsupported-operator] Operator `+` is not supported between objects of type `Basic` and `Literal[1]`
- sympy/functions/combinatorial/factorials.py:986:40: error[unsupported-operator] Operator `+` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[1]`
+ sympy/functions/combinatorial/factorials.py:986:40: error[unsupported-operator] Operator `+` is not supported between objects of type `Basic` and `Literal[1]`
- sympy/functions/combinatorial/factorials.py:986:53: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic | int | float | complex | Any`
+ sympy/functions/combinatorial/factorials.py:986:53: error[unsupported-operator] Operator `-` is not supported between two objects of type `Basic`
- sympy/geometry/point.py:1295:25: error[unresolved-attribute] Attribute `tolist` is not defined on `T2'return@call_highest_priority`, `T1'return@call_highest_priority`, `Expr` in union `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
+ sympy/geometry/point.py:1295:25: error[unresolved-attribute] Attribute `tolist` is not defined on `Expr` in union `MatrixBase | Expr`
- sympy/geometry/polygon.py:1500:12: error[unresolved-attribute] Attribute `is_Number` is not defined on `int`, `float`, `complex` in union `Basic | int | float | complex | Any`
- sympy/geometry/polygon.py:1501:20: error[invalid-argument-type] Argument to function `as_int` is incorrect: Expected `SupportsIndex`, found `Basic | int | float | complex | Any`
+ sympy/geometry/polygon.py:1501:20: error[invalid-argument-type] Argument to function `as_int` is incorrect: Expected `SupportsIndex`, found `Basic`
- sympy/geometry/polygon.py:1502:16: error[unsupported-operator] Operator `<` is not supported between objects of type `Basic | int | float | complex | Any` and `Literal[3]`
+ sympy/geometry/polygon.py:1502:16: error[unsupported-operator] Operator `<` is not supported between objects of type `Basic` and `Literal[3]`
- sympy/geometry/polygon.py:1509:40: error[unresolved-attribute] Attribute `is_number` is not defined on `int`, `float`, `complex` in union `Basic | int | float | complex | Any`
- 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/integrals/tests/test_heurisch.py:389:17: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MutableDenseMatrix`
+ sympy/integrals/tests/test_heurisch.py:390:26: error[not-subscriptable] Cannot subscript object of type `Expr` with no `__getitem__` method
+ sympy/matrices/decompositions.py:1321:16: error[unresolved-attribute] Attribute `diagonalize` is not defined on `Expr` in union `MatrixBase | Expr`
+ sympy/matrices/decompositions.py:1336:16: error[unresolved-attribute] Attribute `diagonalize` is not defined on `Expr` in union `MatrixBase | Expr`
- sympy/matrices/decompositions.py:1321:16: error[unresolved-attribute] Attribute `diagonalize` is not defined on `T2'return@call_highest_priority`, `T1'return@call_highest_priority`, `Expr` in union `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/decompositions.py:1334:13: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MatrixBase`
- sympy/matrices/decompositions.py:1336:16: error[unresolved-attribute] Attribute `diagonalize` is not defined on `T2'return@call_highest_priority`, `T1'return@call_highest_priority`, `Expr` in union `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
- sympy/matrices/decompositions.py:1348:13: error[unsupported-operator] Operator `*` is not supported between objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr` and `MatrixBase`
- sympy/matrices/decompositions.py:1350:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[Tmat@_singular_value_decomposition, Tmat@_singular_value_decomposition, Tmat@_singular_value_decomposition]`, found `tuple[Unknown | MatrixBase, MatrixBase, MatrixBase | Unknown]`
+ sympy/matrices/decompositions.py:1350:12: error[invalid-return-type] Return type does not match returned value: expected `tuple[Tmat@_singular_value_decomposition, Tmat@_singular_value_decomposition, Tmat@_singular_value_decomposition]`, found `tuple[MatrixBase | Expr | Unknown, MatrixBase, MatrixBase | Expr | Unknown]`
- sympy/matrices/eigen.py:328:22: error[invalid-argument-type] Argument to bound method `_as_type` is incorrect: Expected `MatrixBase`, found `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Unknown`
- sympy/matrices/expressions/hadamard.py:81:22: error[invalid-argument-type] Argument to function `validate_matadd_integer` is incorrect: Expected `MatrixExpr`, found `Any | Basic | int | float | complex`
+ sympy/matrices/expressions/hadamard.py:81:22: error[invalid-argument-type] Argument to function `validate_matadd_integer` is incorrect: Expected `MatrixExpr`, found `Basic`
- sympy/matrices/expressions/kronecker.py:109:16: error[unresolved-attribute] Attribute `is_Identity` is not defined on `Basic`, `int`, `float`, `complex` in union `Any | Basic | int | float | complex`
- sympy/matrices/expressions/kronecker.py:110:33: error[unresolved-attribute] Attribute `rows` is not defined on `Basic`, `int`, `float`, `complex` in union `Any | Basic | int | float | complex`
+ sympy/matrices/expressions/kronecker.py:109:16: error[unresolved-attribute] Object of type `Basic` has no attribute `is_Identity`
+ sympy/matrices/expressions/kronecker.py:110:33: error[unresolved-attribute] Object of type `Basic` has no attribute `rows`
- sympy/matrices/expressions/matadd.py:60:22: error[invalid-argument-type] Argument to function `validate_matadd_integer` is incorrect: Expected `MatrixExpr`, found `Unknown | Basic | int | float | complex`
+ sympy/matrices/expressions/matadd.py:60:22: error[invalid-argument-type] Argument to function `validate_matadd_integer` is incorrect: Expected `MatrixExpr`, found `Unknown | Basic`
- sympy/matrices/expressions/tests/test_derivatives.py:551:26: error[unsupported-operator] Operator `+` is not supported between two objects of type `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
+ sympy/matrices/expressions/tests/test_derivatives.py:551:26: error[unsupported-operator] Operator `+` is not supported between two objects of type `MatrixBase | Expr`
- sympy/matrices/expressions/tests/test_matadd.py:36:12: error[unsupported-operator] Operator `+` is not supported between objects of type `MatrixBase` and `T2'return@call_highest_priority | T1'return@call_highest_priority | MatrixBase | Expr`
+ sympy/matrices/expressions/tests/test_matadd.py:36:12: error[unsupported-operator] Operator `+` is not supported between objects of type `MatrixBase` and `MatrixBase | Expr`
+ sympy/matrices/expressions/tests/test_matmul.py:158:68: error[unresolved-attribute] At

... (truncated 575 lines) ...

@mtshiba
Copy link
Collaborator Author

mtshiba commented Feb 10, 2026

My original idea didn't work, but instead I was able to suppress the exponential blowup by implementing a cache for narrow_by_constraint_inner.
I'll continue working on it to see if I can improve performance a bit more.

@mtshiba mtshiba reopened this Feb 12, 2026
@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 12, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-key 0 51 0
unresolved-attribute 0 4 32
possibly-unresolved-reference 0 20 0
invalid-argument-type 1 3 12
unresolved-reference 0 10 0
unsupported-operator 0 1 6
invalid-return-type 2 0 3
not-iterable 0 0 2
unused-type-ignore-comment 1 1 0
invalid-assignment 0 0 1
no-matching-overload 0 1 0
possibly-missing-attribute 0 1 0
type-assertion-failure 0 1 0
Total 4 93 56

Full report with detailed diff (timing results)

@mtshiba mtshiba changed the title [ty] [experiment] improve #23109 TDD-based narrowing [ty] improve complex TDD-based narrowing Feb 12, 2026
..
}) => Some(!resolve_to_literal(operand)?),
_ => None,
#[derive(Copy, Clone)]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the end, this didn't seem to do much to improve the performance degradation, but I don't think there's anything bad that can come from leaving it.

self.record_narrowing_constraint(negated_predicate);
self.record_reachability_constraint(negated_predicate);
let predicate_id = self.record_narrowing_constraint(negated_predicate);
self.record_reachability_constraint_id(predicate_id);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because the reachability constraint and the narrowing constraint point to the same predicate, we can reuse the same ID to save memory. That was the original intention, but this change was actually essential for this PR (it was essential for the Bindings::merge change https://github.com/astral-sh/ruff/pull/23201/changes#r2800954123).
Without this identification, it seems that narrowing would be mistakenly determined to be a non no-op when it should be no-op.

place: ScopedPlaceId,
) -> Type<'db> {
self.narrow_by_constraint_inner(db, predicates, id, base_ty, place, None)
let mut memo = FxHashMap::default();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Caching helps mitigate the exponential blowup reported in 5fd9a9c.

{
ScopedNarrowingConstraint::ALWAYS_TRUE
} else {
// A branch contributes narrowing only when it is reachable.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This technique is possible because narrowing and reachability are now managed in the same data structure. The narrowing of a/b is triggered when the reachability of a/b is ALWAYS_TRUE.
That is, gate each narrowing constraint with each reachability constraint with and.

@mtshiba
Copy link
Collaborator Author

mtshiba commented Feb 12, 2026

I've tried various things, but this is the limit. I'm out of ideas for optimization, and the codspeed profiling results show no abnormal hot spots.

So I'll mark this PR as ready for review.

@mtshiba mtshiba marked this pull request as ready for review February 12, 2026 20:48
mtshiba added a commit that referenced this pull request Feb 20, 2026

/// Inner recursive helper that accumulates narrowing constraints along each TDD path.
#[allow(clippy::too_many_arguments)]
fn narrow_by_constraint_inner<'db>(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function was the hotspot in most of the performance degradation cases, as we started to build complex narrowing TDD and the number of recursive calls grew significantly.

@mtshiba
Copy link
Collaborator Author

mtshiba commented Feb 23, 2026

I believe I've addressed all the performance issues I was concerned about (please also see #23520, #23521).
As a result, there are many changes. Please let me know if there are any parts you would like to be split into a separate PR.

@mtshiba mtshiba marked this pull request as ready for review February 23, 2026 16:27
/// ...
/// case _: pass
/// ```
fn benchmark_large_union_narrowing(criterion: &mut Criterion) {
Copy link
Member

Choose a reason for hiding this comment

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

this benchmark currently shows up as "new" in the codspeed report, so we can't see how much this PR improves performance on this benchmark relative to main. It might be better to add this benchmark in a standalone PR, wait for codspeed to finish on that PR branch, and then rebase this PR on top of that PR branch. Then Codspeed should tell us how much this PR improves performance on this benchmark.

}

/// Inner recursive helper that accumulates narrowing constraints along each TDD path.
#[allow(clippy::too_many_arguments)]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]

/// if reachability analysis etc. fails when analysing these enums.
const MAX_NON_RECURSIVE_UNION_ENUM_LITERALS: usize = 8192;

#[allow(clippy::struct_excessive_bools)]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[allow(clippy::struct_excessive_bools)]
#[expect(clippy::struct_excessive_bools)]

}
}

#[allow(clippy::unnecessary_wraps)]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[allow(clippy::unnecessary_wraps)]
#[expect(clippy::unnecessary_wraps)]

)
}

#[allow(clippy::unnecessary_wraps)]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[allow(clippy::unnecessary_wraps)]
#[expect(clippy::unnecessary_wraps)]

Comment on lines +316 to +319
// Fast path for intersection types: use set-based subset check instead of
// the full `has_relation_to` machinery. This is critical for narrowing where
// many intersection types with overlapping positive elements are produced.
if let (Type::Intersection(self_inter), Type::Intersection(other_inter)) = (self, other) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand this comment: why is it important for this fast path to be in Type::has_relation_to() (an uncached function) rather than Type::has_relation_to_impl (a cached function)? Can this fast path not be applied to the (Type::Intersection(...), Type::Intersection(...)) branch of Type::has_relation_to_impl?

Comment on lines +12961 to +12972
#[salsa::tracked(
cycle_initial=|_, id, _, _| Type::divergent(id),
cycle_fn=|db, cycle, previous: &Type<'db>, result: Type<'db>, _, _| {
result.cycle_normalized(db, *previous, cycle)
},
heap_size=ruff_memory_usage::heap_size
)]
fn from_two_elements(db: &'db dyn Db, a: Type<'db>, b: Type<'db>) -> Type<'db> {
IntersectionBuilder::new(db)
.positive_elements([a, b])
.build()
}
Copy link
Member

Choose a reason for hiding this comment

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

I would be very interested to see the effect of this change (and the changes elsewhere to use this new constructor) in isolation, pulled out into a standalone PR. I suspect it may be a significant factor in both the memory-usage increase on this branch and the pydantic performance improvement on this branch

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