Skip to content

[ty] improve complex TDD-based narrowing#23201

Draft
mtshiba wants to merge 78 commits intoastral-sh:mainfrom
mtshiba:improve-23109
Draft

[ty] improve complex TDD-based narrowing#23201
mtshiba wants to merge 78 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.
    ...

↓ P.S. spitted to


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 713.90MB 732.22MB +2.57% (18.32MB)
sphinx 272.28MB 279.50MB +2.65% (7.23MB)
trio 121.20MB 124.53MB +2.74% (3.32MB)
flake8 49.47MB 50.95MB +2.99% (1.48MB)

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
semantic_index 191.82MB 209.61MB +9.27% (17.79MB)
all_negative_narrowing_constraints_for_expression 2.35MB 0.00B -100.00% (2.35MB)
all_narrowing_constraints_for_expression 5.72MB 4.97MB -13.11% (767.66kB)
IntersectionType<'db>::from_two_elements_ 0.00B 752.36kB +752.36kB (new)
NarrowingConstraint 0.00B 699.31kB +699.31kB (new)
infer_expression_types_impl 61.79MB 62.38MB +0.95% (601.76kB)
IntersectionType<'db>::from_two_elements_::interned_arguments 0.00B 517.77kB +517.77kB (new)
DualNarrowingConstraints 0.00B 390.84kB +390.84kB (new)
infer_definition_types 87.80MB 88.09MB +0.33% (293.57kB)
infer_expression_type_impl 15.21MB 15.49MB +1.83% (285.67kB)
infer_scope_types_impl 52.65MB 52.72MB +0.13% (68.59kB)
loop_header_reachability 509.92kB 556.41kB +9.12% (46.49kB)
StaticClassLiteral<'db>::implicit_attribute_inner_ 9.91MB 9.95MB +0.44% (44.91kB)
Type<'db>::member_lookup_with_policy_ 15.22MB 15.26MB +0.22% (34.33kB)
is_redundant_with_impl 5.64MB 5.61MB -0.58% (33.69kB)
... 39 more

sphinx

Name Old New Diff Outcome
semantic_index 69.45MB 75.63MB +8.89% (6.17MB)
all_negative_narrowing_constraints_for_expression 824.40kB 0.00B -100.00% (824.40kB)
NarrowingConstraint 0.00B 647.95kB +647.95kB (new)
IntersectionType<'db>::from_two_elements_ 0.00B 567.67kB +567.67kB (new)
IntersectionType<'db>::from_two_elements_::interned_arguments 0.00B 307.91kB +307.91kB (new)
DualNarrowingConstraints 0.00B 273.23kB +273.23kB (new)
all_narrowing_constraints_for_expression 1.79MB 1.57MB -12.08% (220.95kB)
infer_expression_type_impl 3.36MB 3.53MB +4.90% (168.71kB)
infer_expression_types_impl 22.02MB 22.15MB +0.56% (127.39kB)
IntersectionType 1.03MB 954.37kB -9.77% (103.33kB)
infer_definition_types 24.41MB 24.47MB +0.27% (67.40kB)
loop_header_reachability 436.46kB 477.51kB +9.40% (41.04kB)
infer_scope_types_impl 15.84MB 15.88MB +0.25% (40.61kB)
is_redundant_with_impl 1.86MB 1.84MB -1.05% (19.92kB)
is_redundant_with_impl::interned_arguments 2.15MB 2.14MB -0.85% (18.73kB)
... 36 more

trio

Name Old New Diff Outcome
semantic_index 33.39MB 36.33MB +8.78% (2.93MB)
NarrowingConstraint 0.00B 166.86kB +166.86kB (new)
IntersectionType<'db>::from_two_elements_ 0.00B 158.09kB +158.09kB (new)
all_negative_narrowing_constraints_for_expression 148.77kB 0.00B -100.00% (148.77kB)
IntersectionType<'db>::from_two_elements_::interned_arguments 0.00B 103.81kB +103.81kB (new)
DualNarrowingConstraints 0.00B 79.15kB +79.15kB (new)
all_narrowing_constraints_for_expression 487.04kB 413.78kB -15.04% (73.26kB)
infer_expression_type_impl 1.49MB 1.54MB +3.65% (55.55kB)
infer_expression_types_impl 7.20MB 7.23MB +0.38% (28.01kB)
infer_definition_types 7.61MB 7.62MB +0.23% (17.66kB)
loop_header_reachability 144.16kB 155.94kB +8.17% (11.78kB)
is_redundant_with_impl 487.80kB 479.30kB -1.74% (8.51kB)
is_redundant_with_impl::interned_arguments 567.96kB 560.31kB -1.35% (7.65kB)
infer_scope_types_impl 4.90MB 4.90MB +0.09% (4.56kB)
UnionType 335.02kB 332.30kB -0.81% (2.72kB)
... 35 more

flake8

Name Old New Diff Outcome
semantic_index 15.29MB 16.68MB +9.13% (1.40MB)
all_negative_narrowing_constraints_for_expression 36.07kB 0.00B -100.00% (36.07kB)
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.19kB 57.32kB -13.41% (8.88kB)
infer_definition_types 1.89MB 1.90MB +0.28% (5.34kB)
infer_expression_type_impl 170.85kB 174.77kB +2.30% (3.92kB)
loop_header_reachability 20.51kB 21.64kB +5.54% (1.14kB)
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)
... 11 more

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 10, 2026

Merging this PR will improve performance by 19.82%

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

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime pydantic 7.4 s 6.1 s +19.82%
🆕 Simulation ty_micro[large_union_narrowing] N/A 296.8 ms N/A

Comparing mtshiba:improve-23109 (ff76ba0) with main (85a6a44)

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[Unknown | int | str | ... omitted 3 union elements]`
+ lib/spack/spack/detection/path.py:169:33: error[invalid-argument-type] Argument to function `dedupe_paths` is incorrect: Expected `list[str]`, found `Unknown | list[int | bytes | PathLike[str] | ... omitted 3 union elements]`
- lib/spack/spack/llnl/util/filesystem.py:1668:35: error[invalid-argument-type] Argument to function `exists` is incorrect: Expected `int | str | bytes | PathLike[str] | PathLike[bytes]`, found `Sized | Unknown`
+ lib/spack/spack/llnl/util/filesystem.py:1668:35: error[invalid-argument-type] Argument to function `exists` is incorrect: Expected `int | str | bytes | PathLike[str] | PathLike[bytes]`, found `Unknown | Sized`
- lib/spack/spack/llnl/util/filesystem.py:1674:25: error[invalid-argument-type] Argument to function `move` is incorrect: Expected `str | PathLike[str]`, found `Sized | Unknown`
+ lib/spack/spack/llnl/util/filesystem.py:1674:25: error[invalid-argument-type] Argument to function `move` is incorrect: Expected `str | PathLike[str]`, found `Unknown | Sized`
- 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`
- lib/spack/spack/verify_libraries.py:164:46: error[invalid-argument-type] Argument to function `candidate_matches` is incorrect: Expected `bytes`, found `Unknown | bytes | str | PathLike[str] | PathLike[bytes]`
+ lib/spack/spack/verify_libraries.py:164:46: error[invalid-argument-type] Argument to function `candidate_matches` is incorrect: Expected `bytes`, found `bytes | Unknown | str | PathLike[str] | PathLike[bytes]`
- lib/spack/spack/verify_libraries.py:165:17: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown | bytes | str | PathLike[str] | PathLike[bytes]` and value of type `Unknown | bytes | str | PathLike[str] | PathLike[bytes]` on object of type `dict[bytes, bytes]`
+ lib/spack/spack/verify_libraries.py:165:17: error[invalid-assignment] Invalid subscript assignment with key of type `bytes | Unknown | str | PathLike[str] | PathLike[bytes]` and value of type `bytes | Unknown | str | PathLike[str] | PathLike[bytes]` on object of type `dict[bytes, bytes]`
- lib/spack/spack/verify_libraries.py:170:57: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `list[bytes]`, found `list[Unknown | bytes | str | PathLike[str] | PathLike[bytes]]`
+ lib/spack/spack/verify_libraries.py:170:57: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `list[bytes]`, found `list[bytes | Unknown | str | PathLike[str] | PathLike[bytes]]`
- lib/spack/spack/verify_libraries.py:170:69: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `list[bytes]`, found `list[Unknown | bytes | str | PathLike[str] | PathLike[bytes]]`
+ lib/spack/spack/verify_libraries.py:170:69: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `list[bytes]`, found `list[bytes | Unknown | str | PathLike[str] | PathLike[bytes]]`
- Found 4383 diagnostics
+ Found 4381 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

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, ...]]`

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

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 2181 diagnostics
+ Found 2182 diagnostics

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`

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`
- pylint/checkers/refactoring/implicit_booleaness_checker.py:219:24: error[unresolved-attribute] Attribute `as_string` is not defined on `str` in union `str | Unknown`
+ pylint/checkers/refactoring/implicit_booleaness_checker.py:219:24: error[unresolved-attribute] Attribute `as_string` is not defined on `str` in union `Unknown | str`
- pylint/checkers/refactoring/implicit_booleaness_checker.py:219:62: error[unresolved-attribute] Attribute `as_string` is not defined on `str` in union `str | Unknown`
+ pylint/checkers/refactoring/implicit_booleaness_checker.py:219:62: error[unresolved-attribute] Attribute `as_string` is not defined on `str` in union `Unknown | str`
- pylint/checkers/refactoring/implicit_booleaness_checker.py:222:27: error[unresolved-attribute] Attribute `as_string` is not defined on `str` in union `str | (Unknown & ~None)`
+ pylint/checkers/refactoring/implicit_booleaness_checker.py:222:27: error[unresolved-attribute] Attribute `as_string` is not defined on `str` in union `(Unknown & ~None) | str`
- pylint/checkers/refactoring/implicit_booleaness_checker.py:236:29: error[unresolved-attribute] Attribute `as_string` is not defined on `str` in union `str | Unknown`
+ pylint/checkers/refactoring/implicit_booleaness_checker.py:236:29: error[unresolved-attribute] Attribute `as_string` is not defined on `str` in union `Unknown | str`
- pylint/checkers/refactoring/implicit_booleaness_checker.py:239:29: error[unresolved-attribute] Attribute `as_string` is not defined on `str` in union `str | Unknown`
+ pylint/checkers/refactoring/implicit_booleaness_checker.py:239:29: error[unresolved-attribute] Attribute `as_string` is not defined on `str` in union `Unknown | str`
- Found 220 diagnostics
+ Found 219 diagnostics

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 3194 diagnostics
+ Found 3143 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

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 471 diagnostics
+ Found 470 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)`

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`

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]`

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

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` in union `Unknown | ((...) -> Any)`
+ 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/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` has no attribute `__name__`
+ 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:404:68: 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/utilities/asyncutils.py:198:16: error[invalid-return-type] Return type does not match returned value: expected `R@run_coro_as_sync | None`, found `CoroutineType[Any, Any, R@run_coro_as_sync | None] | R@run_coro_as_sync | None`
+ src/prefect/utilities/asyncutils.py:207:20: error[invalid-return-type] Return type does not match returned value: expected `R@run_coro_as_sync | None`, found `CoroutineType[Any, Any, R@run_coro_as_sync | None] | R@run_coro_as_sync | None`
- 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`
- Found 5926 diagnostics
+ Found 5924 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

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

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

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/debugging/_redaction.py:16:5: error[unsupported-operator] Operator `|` is not supported between objects of type `frozenset[str | Unknown]` and `Unknown | EnvVariable[set[Unknown]]`
+ ddtrace/debugging/_redaction.py:16:5: error[unsupported-operator] Operator `|` is not supported between objects of type `frozenset[Unknown | str]` and `Unknown | EnvVariable[set[Unknown]]`
- 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`
- tests/tracer/test_span.py:193:29: error[invalid-argument-type] Argument to bound method `set_metric` is incorrect: Expected `int | float`, found `int | Unknown | None | ... omitted 6 union elements`
+ tests/tracer/test_span.py:193:29: error[invalid-argument-type] Argument to bound method `set_metric` is incorrect: Expected `int | float`, found `str | Unknown | None | ... omitted 6 union elements`

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

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)`

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`

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

materialize (https://github.com/MaterializeInc/materialize)
+ misc/python/materialize/cli/mz_workload_anonymize.py:251:13: error[no-matching-overload] No overload of bound method `join` matches arguments
- Found 529 diagnostics
+ Found 530 diagnostics

sympy (https://github.com/sympy/sympy)
- sympy/algebras/tests/test_quaternion.py:422:33: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/codegen/tests/test_matrix_nodes.py:27:21: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/geometry/tests/test_util.py:128:55: error[invalid-argument-type] Argument to function `subsets` is incorrect: Expected `Sequence[Unknown]`, found `set[Point2D | Unknown]`
+ sympy/geometry/tests/test_util.py:128:55: error[invalid-argument-type] Argument to function `subsets` is incorrect: Expected `Sequence[Unknown]`, found `set[Unknown | Point2D]`
- sympy/matrices/eigen.py:1202:37: error[unresolved-attribute] Object of type `T2'return@call_highest_priority | T1'return@call_highest_priority` has no attribute `pow`
- 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 | int | float | complex | Any`
- 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:109:16: error[unresolved-attribute] Attribute `is_Identity` is not defined on `Basic`, `int`, `float`, `complex` in union `Basic | int | float | complex | Any`
- 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:110:33: error[unresolved-attribute] Attribute `rows` is not defined on `Basic`, `int`, `float`, `complex` in union `Basic | int | float | complex | Any`
- sympy/matrices/expressions/tests/test_blockmatrix.py:235:13: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/expressions/tests/test_blockmatrix.py:235:33: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/expressions/tests/test_blockmatrix.py:235:53: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/expressions/tests/test_blockmatrix.py:459:12: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- 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 `MatrixBase | Expr`
- sympy/matrices/expressions/tests/test_matpow.py:124:47: error[unsupported-operator] Operator `+` is not supported between two objects of type `ImmutableDenseMatrix`
- sympy/matrices/inverse.py:385:11: error[unsupported-operator] Operator `-` is not supported between objects of type `MatrixBase` and `MatrixBase | Expr | Unknown`
- sympy/matrices/inverse.py:393:11: error[unsupported-operator] Operator `+` is not supported between objects of type `MatrixBase` and `MatrixBase | Expr | Unknown`
- sympy/matrices/matrixbase.py:979:18: error[unsupported-operator] Operator `+` is not supported between two objects of type `Self@_eval_wilkinson`
- sympy/matrices/matrixbase.py:2957:16: error[invalid-return-type] Return type does not match returned value: expected `Self@_eval_pow_by_cayley`, found `Self@_eval_pow_by_cayley | T2'return@call_highest_priority | T1'return@call_highest_priority | Unknown`
- sympy/matrices/matrixbase.py:3256:16: error[invalid-return-type] Return type does not match returned value: expected `MatrixBase`, found `T2'return@call_highest_priority | T1'return@call_highest_priority`
- sympy/matrices/matrixbase.py:3256:29: error[invalid-argument-type] Argument is incorrect: Expected `T2'return@call_highest_priority | T1'return@call_highest_priority`, found `MatrixBase`
- sympy/matrices/matrixbase.py:3310:16: error[unsupported-operator] Operator `+` is not supported between two objects of type `MatrixBase`
- sympy/matrices/matrixbase.py:3314:16: error[invalid-return-type] Return type does not match returned value: expected `Tmat@__sub__`, found `MatrixBase`
- sympy/matrices/matrixbase.py:4386:16: error[unsupported-operator] Operator `+` is not supported between two objects of type `Self@add`
- sympy/matrices/matrixbase.py:4923:16: error[invalid-return-type] Return type does not match returned value: expected `Self@analytic_func`, found `Self@analytic_func | T2'return@call_highest_priority | T1'return@call_highest_priority | Unknown`
- sympy/matrices/repmatrix.py:321:17: error[unsupported-operator] Operator `-` is not supported between two objects of type `Self@_eval_is_symmetric`
- sympy/matrices/solvers.py:741:12: error[invalid-return-type] Return type does not match returned value: expected `Tmat@_pinv_solve`, found `T2'return@call_highest_priority | T1'return@call_highest_priority`
- sympy/matrices/tests/test_commonmatrix.py:1249:31: error[unsupported-operator] Operator `+` is not supported between objects of type `MutableDenseMatrix` and `ImmutableDenseNDimArray`
- sympy/matrices/tests/test_eigen.py:406:20: error[invalid-argument-type] Argument to function `max` is incorrect: Expected `Iterable[Unknown]`, found `MatrixBase | Unknown`
- sympy/matrices/tests/test_immutable.py:105:23: error[unsupported-operator] Operator `+` is not supported between two objects of type `ImmutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:121:12: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:123:32: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:141:12: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:2179:22: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:2207:26: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:2908:21: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:2921:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:2936:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:2937:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:2948:14: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:3471:21: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:3478:12: error[unresolved-attribute] Attribute `rank` is not defined on `MatrixExpr` in union `MatrixBase | MatrixExpr | Unknown`
- sympy/matrices/tests/test_matrices.py:3479:12: error[unresolved-attribute] Attribute `rank` is not defined on `MatrixExpr` in union `MatrixBase | MatrixExpr | Unknown`
- sympy/matrices/tests/test_matrixbase.py:491:12: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:493:32: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:544:12: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:823:31: error[unsupported-operator] Operator `+` is not supported between objects of type `MutableDenseMatrix` and `ImmutableDenseNDimArray`
- sympy/matrices/tests/test_matrixbase.py:876:12: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:878:32: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:900:12: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:2931:22: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:2959:26: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:3610:21: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:3624:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:3639:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:3640:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:3652:14: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_reductions.py:377:21: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_reductions.py:384:12: error[unresolved-attribute] Attribute `rank` is not defined on `MatrixExpr` in union `MatrixBase | MatrixExpr | Unknown`
- sympy/matrices/tests/test_reductions.py:385:12: error[unresolved-attribute] Attribute `rank` is not defined on `MatrixExpr` in union `MatrixBase | MatrixExpr | Unknown`
- sympy/matrices/tests/test_solvers.py:68:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_sparse.py:573:12: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableSparseMatrix`
- sympy/matrices/tests/test_sparse.py:577:52: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableSparseMatrix`
- sympy/matrices/tests/test_sparse.py:593:17: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableSparseMatrix`
- sympy/ntheory/factor_.py:529:38: error[not-iterable] Object of type `Unknown | None` may not be iterable
+ sympy/ntheory/factor_.py:529:38: error[not-iterable] Object of type `(Unknown & ~None) | None` may not be iterable
- sympy/parsing/autolev/test-examples/ruletest5.py:13:6: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:16:38: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:16:84: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:16:131: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:21:44: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:21:90: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:21:137: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:25:37: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:25:83: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:25:130: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/physics/control/tests/test_lti.py:3777:31: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/physics/control/tests/test_lti.py:3777:38: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/physics/mechanics/lagrange.py:222:23: error[unsupported-operator] Operator `-` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/physics/mechanics/lagrange.py:346:17: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/physics/mechanics/linearize.py:217:28: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/physics/mechanics/linearize.py:229:29: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/physics/mechanics/linearize.py:241:29: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/physics/mechanics/tests/test_jointsmethod.py:247:17: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/physics/mechanics/tests/test_jointsmethod.py:249:17: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/physics/quantum/tests/test_represent.py:89:17: error[unsupported-operator] Operator `+` is not supported between objects of type `MatrixBase | Expr` and `MatrixBase`
- sympy/physics/quantum/tests/test_represent.py:91:24: error[unsupported-operator] Operator `-` is not supported between two objects of type `MatrixBase | Expr`
- sympy/physics/quantum/tests/test_represent.py:93:28: error[unsupported-operator] Operator `+` is not supported between two objects of type `MatrixBase | Expr`
- sympy/physics/vector/functions.py:380:21: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Iterable[Unknown]`, found `MatrixBase | Unknown`
- sympy/polys/domains/domain.py:626:40: error[invalid-argument-type] Argument to bound method `from_sympy` is incorrect: Expected `Expr`, found `(Es@convert & Basic & ~Er@Domain & ~MPZ & ~DomainElement) | (Expr & ~Er@Domain & ~MPZ & ~DomainElement)`
+ sympy/polys/domains/domain.py:626:40: error[invalid-argument-type] Argument to bound method `from_sympy` is incorrect: Expected `Expr`, found `(Es@convert & Unknown & Basic & ~Er@Domain & ~MPZ & ~DomainElement) | (Expr & Unknown & ~Er@Domain & ~MPZ & ~DomainElement) | (Es@convert & MPQ & Basic & ~Er@Domain & ~MPZ & ~DomainElement) | (Expr & MPQ & ~Er@Domain & ~MPZ & ~DomainElement)`
- sympy/polys/fields.py:101:24: error[unresolved-attribute] Attribute `as_numer_denom` is not defined on `Basic`, `int`, `float`, `complex` in union `Any | Basic | int | float | complex`
+ sympy/polys/fields.py:101:24: error[unresolved-attribute] Attribute `as_numer_denom` is not defined on `Basic`, `int`, `float`, `complex` in union `Basic | int | float | complex | Any`
- sympy/polys/polyoptions.py:472:61: error[invalid-argument-type] Argument to bound method `poly_ring` is incorrect: Expected `str | Expr`, found `Any | Basic | int | float | complex`
+ sympy/polys/polyoptions.py:472:61: error[invalid-argument-type] Argument to bound method `poly_ring` is incorrect: Expected `str | Expr`, found `Basic | int | float | complex | Any`
- sympy/polys/polyoptions.py:474:61: error[invalid-argument-type] Argument to bound method `poly_ring` is incorrect: Expected `str | Expr`, found `Any | Basic | int | float | complex`
+ sympy/polys/polyoptions.py:474:61: error[invalid-argument-type] Argument to bound method `poly_ring` is incorrect: Expected `str | Expr`, found `Basic | int | float | complex | Any`
- sympy/polys/polyoptions.py:476:61: error[invalid-argument-type] Argument to bound method `poly_ring` is incorrect: Expected `str | Expr`, found `Any | Basic | int | float | complex`
+ sympy/polys/polyoptions.py:476:61: error[invalid-argument-type] Argument to bound method `poly_ring` is incorrect: Expected `str | Expr`, found `Basic | int | float | complex | Any`
- sympy/polys/polyoptions.py:478:63: error[invalid-argument-type] Argument to bound method `poly_ring` is incorrect: Expected `str | Expr`, found `Any | Basic | int | float | complex`
+ sympy/polys/polyoptions.py:478:63: error[invalid-argument-type] Argument to bound method `poly_ring` is incorrect: Expected `str | Expr`, found `Basic | int | float | complex | Any`
- sympy/polys/polyoptions.py:480:63: error[invalid-argument-type] Argument to bound method `poly_ring` is incorrect: Expected `str | Expr`, found `Any | Basic | int | float | complex`
+ sympy/polys/polyoptions.py:480:63: error[invalid-argument-type] Argument to bound method `poly_ring` is incorrect: Expected `str | Expr`, found `Basic | int | float | complex | Any`
- sympy/polys/polyoptions.py:482:61: error[invalid-argument-type] Argument to bound method `poly_ring` is incorrect: Expected `str | Expr`, found `Any | Basic | int | float | complex`
+ sympy/polys/polyoptions.py:482:61: error[invalid-argument-type] Argument to bound method `poly_ring` is incorrect: Expected `str | Expr`, found `Basic | int | float | complex | Any`
- sympy/polys/polyoptions.py:492:62: error[invalid-argument-type] Argument to bound method `frac_field` is incorrect: Expected `str | Expr`, found `Any | Basic | int | float | complex`
+ sympy/polys/polyoptions.py:492:62: error[invalid-argument-type] Argument to bound method `frac_field` is incorrect: Expected `str | Expr`, found `Basic | int | float | complex | Any`
- sympy/polys/polyoptions.py:494:62: error[invalid-argument-type] Argument to bound method `frac_field` is incorrect: Expected `str | Expr`, found `Any | Basic | int | float | complex`
+ sympy/polys/polyoptions.py:494:62: error[invalid-argument-type] Argument to bound method `frac_field` is incorrect: Expected `str | Expr`, found `Basic | int | float | complex | Any`
- sympy/printing/preview.py:377:45: error[invalid-argument-type] Argument to function `move` is incorrect: Argument type `Unknown | None` does not satisfy upper bound `str | PathLike[str]` of type variable `_StrPathT`
+ sympy/printing/preview.py:377:45: error[invalid-argument-type] Argument to function `move` is incorrect: Argument type `(Unknown & ~None) | None` does not satisfy upper bound `str | PathLike[str]` of type variable `_StrPathT`
- sympy/printing/preview.py:380:13: error[unresolved-attribute] Attribute `write` is not defined on `None` in union `Unknown | None`
+ sympy/printing/preview.py:380:13: error[unresolved-attribute] Attribute `write` is not defined on `None` in union `None | (Unknown & ~None)`
- sympy/series/order.py:269:52: error[invalid-argument-type] Argument to bound method `as_independent` is incorrect: Expected `Basic | type[Basic]`, found `Any | Basic | int | float | complex`
+ sympy/series/order.py:269:52: error[invalid-argument-type] Argument to bound method `as_independent` is incorrect: Expected `Basic | type[Basic]`, found `Basic | int | float | complex | Any`
- sympy/series/order.py:269:52: error[invalid-argument-type] Argument to bound method `as_independent` is incorrect: Expected `Basic | type[Basic]`, found `Any | Basic | int | float | complex`
+ sympy/series/order.py:269:52: error[invalid-argument-type] Argument to bound method `as_independent` is incorrect: Expected `Basic | type[Basic]`, found `Basic | int | float | complex | Any`
- sympy/series/order.py:269:52: error[invalid-argument-type] Argument to bound method `as_independent` is incorrect: Expected `Basic | type[Basic]`, found `Any | Basic | int | float | complex`
+ sympy/series/order.py:269:52: error[invalid-argument-type] Argument to bound method `as_independent` is incorrect: Expected `Basic | type[Basic]`, found `Basic | int | float | complex | Any`
- sympy/series/order.py:287:45: error[unsupported-operator] Unary operator `-` is not supported for object of type `Any | Basic | int | float | complex`
+ sympy/series/order.py:287:45: error[unsupported-operator] Unary operator `-` is not supported for object of type `Basic | int | float | complex | Any`
- sympy/series/order.py:288:48: error[unsupported-operator] Operator `**` is not supported between objects of type `Any | Basic | int | float | complex` and `Basic`
+ sympy/series/order.py:288:48: error[unsupported-operator] Operator `**` is not supported between objects of type `Basic | int | float | complex | Any` and `Basic`
- sympy/series/order.py:291:49: error[unsupp

... (truncated 192 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 2 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 5 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

/// 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
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?

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 change was split into #23555)
Looking at the codspeed result, it seems that placing this processing outside of is_redundant_with_impl(has_relation_to_impl) actually improves performance.
I think the cache hit rate is low in cases where this fast path is effective.

@sharkdp
Copy link
Contributor

sharkdp commented Feb 24, 2026

Thank you very much for working on this.

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.

I know this is a bit of work, but it would really great if we could split out all of the optimizations that make sense in isolation.

In order of importance:

a lot of these sound like they might improve performance on main as well, i.e. without the main change being proposed here. It might be valuable to see benchmark results for each of these.

sharkdp pushed a commit that referenced this pull request Feb 25, 2026
## Summary

From #23201 (comment)

Let's merge this benchmark into main ahead of #23201 so that we can see
the impact of the changes.

## Test Plan

`benchmark_large_union_narrowing` added to `ruff_benchmark/ty.rs`
sharkdp added a commit that referenced this pull request Feb 25, 2026
## Summary

From #23201 (comment)

This could bring a significant performance improvement to main, so I'm
breaking it out as a standalone PR.

## Test Plan

N/A

---------

Co-authored-by: David Peter <[email protected]>
@sharkdp sharkdp marked this pull request as draft February 27, 2026 20:23
@sharkdp
Copy link
Contributor

sharkdp commented Feb 27, 2026

@mtshiba I'm moving this to draft for now, as it is my understanding that we're still pulling things out of this PR. Please feel free to move it back to review once it's ready. If you do that before, say, March 6th, please feel free to unassign myself as reviewer and close+open this PR to get someone else as reviewer, as I'm out for a few days.

dcreager pushed a commit that referenced this pull request Feb 27, 2026
## Summary

Implement hash-consing for several fields in `UseDefMap` to reduce
memory usage.

The rationale for this optimization is the size and high duplication
rate of the structs used in `UseDefMap`. The size of each struct is:

* Bindings: 40
* PlaceState: 64
* ReachableDefinitions: 64
* EnclosingSnapshot: 40

These elements are stored within `IndexVec` where duplication of
elements can occur.
For example, taking these statistics (duplication rate) with hydra-zen
yields the following:
- bindings_by_use: 65.13%
- end_of_scope_members: 57.37%
- enclosing_snapshots: 57.18%
- reachable_definitions_by_member: 34.58%
- declarations_by_binding: 32.70%
- bindings_by_definition: 27.84%
- end_of_scope_symbols: 21.25%
- reachable_definitions_by_symbol: 15.70%

The disparity in duplication rates between symbols and members was a bit
surprising, but can be explained as follows: `obj.attr` and `obj["k"]`
might be tracked, but often end up in a similar undefined/unbound state,
leading to a large number of identical `PlaceState` instances.

This PR implements hash-consing for these fields. Specifically, each
`IndexVec` for these fields will only store IDs for each struct, and the
actual struct instances will be stored in another `IndexVec` without
duplication.

According to the memory usage report, this change reduced the size of
`SemanticIndex` by about 10%.

## Performance analysis

What this PR is trying to do involves a trade-off between time
complexity and space complexity.
In #23201, I aimed to achieve a more significant reduction in memory
consumption by interning `Bindings`, but this resulted in a major
regression in time performance, so I decided to manually intern only
items that seemed to have a high effect.
This PR change is not very effective for microbenchmarks, and rather
adds a time cost (due to hash calculations). However, looking at the
trends in the memory report, it seems that for large codebases, it can
achieve significant memory savings with relatively little overhead. The
larger the `UseDefMap`, the greater the reduction, so I think it's worth
to do this.

The commit that achieved the greatest memory consumption reduction in
this PR was b9d067a, but it was
reverted because it exceeded the threshold for codspeed microbenchmarks.
There was almost no impact on walltime benchmarks (in fact, some even
showed slight improvements).

## Test Plan

N/A
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