Skip to content

[ty] loop control flow analysis using loop header definitions#22794

Merged
oconnor663 merged 1 commit intomainfrom
jack/cyclic_control_flow
Feb 13, 2026
Merged

[ty] loop control flow analysis using loop header definitions#22794
oconnor663 merged 1 commit intomainfrom
jack/cyclic_control_flow

Conversation

@oconnor663
Copy link
Contributor

@oconnor663 oconnor663 commented Jan 22, 2026

This is a draft PR to trigger CI and an ecosystem report. I still need to "own" some of Claude's code here, but all tests are plausibly passing. I expect the ecosystem report will have a lot of findings. I'm also not especially optimistic about the CodSpeed numbers. (This PR adds an extra preliminary AST pass to every loop body.)

CodSpeed turned out not as bad as I was fearing. I still need to write a proper description here and disposition the ecosystem results, but @carljm this is ready for a review pass :)


Major moving parts:

  • while loops and for loops now synthesize "loop header definitions". See SemanticIndexBuilder::visit_stmt. This is a new type of definition that collects all the bindings that reach a loop-back edge (the end of the loop body, or a continue statement), making these visible to all uses in the loop (as opposed to just the uses that come after).
  • Because these loop header definitions need to be in-scope as we walk the body of the loop, we need to know in advance which places (both "symbols" and "members") are bound in the loop. For that we do a preliminary walk that collects bound places but does not descend into nested scopes. See LoopBindingsVisitor. This is an example of something that's pretty easy to get working with Claude (it's happy to write piles of code), but which (in the old days?) we might not be thrilled about maintaining long term. I'm curious whether anyone has alternative ideas for solving this problem.
  • We can't mutate the loop header definitions once we've established them, but we don't know all the bindings they refer to until we complete the "real" walk of the loop body. (For example, if the last statement in the body is a break, it could be that no bindings loop-back.) We solve this with a layer of indirection. The loop header definitions hold a LoopToken, which uniquely identifies the loop but otherwise holds no data. Then we assemble the bindings we collect during the walk into a LoopHeader struct. Finally, we use the Salsa specify feature to connect the LoopToken to the LoopHeader.
  • Unlike other types of definitions, loop header definitions don't shadow preexisting bindings. Bindings from before the loop (including UNBOUND) follow control flow into the loop body normally and remain visible after the loop. Alternatively I could've "snapshotted" all the bindings at loop entry and relied entirely on "looking through" the loop header definitions, but "don't shadow" was the first approach Claude and I managed to get working :) I'm curious if anyone has strong opinions about this design choice.
  • The initial implementation ran into a panic in the ecosystem tests, in sympy. It turned out to be this loop, which 1) binds a variable cyclically in the loop body, 2) using a tuple-unpacking assignment, and 3) uses the same variable as an if condition around that binding. A couple of the new mdtests are a minimized version of this. With a lot of help from Carl, it turned out that the fix for this cycle was to more aggressively eliminate Divergent from intersections. These changes make sense in the abstract (Divergent should behave like Never in unions and intersections), but I still don't fully understand the evolution of the Salsa cycle that these changes fix. If you want to see the panic for yourself, undo this PR's changes to crates/ty_python_semantic/src/types.rs and run the while_loop.md or for.md mdtests.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 22, 2026

Typing conformance results

No changes detected ✅

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 22, 2026

Merging this PR will degrade performance by 23.27%

❌ 3 regressed benchmarks
✅ 21 untouched benchmarks
⏩ 30 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime sympy 55.9 s 70.5 s -20.65%
Simulation ty_check_file[cold] 133.5 ms 146.6 ms -8.98%
Simulation ty_check_file[incremental] 6.3 ms 8.2 ms -23.27%

Comparing jack/cyclic_control_flow (29e3110) with main (a2f11d2)

Open in CodSpeed

Footnotes

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

@oconnor663 oconnor663 added ty Multi-file analysis & type inference ecosystem-analyzer labels Jan 22, 2026
@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 22, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
possibly-unresolved-reference 319 0 0
unresolved-attribute 63 1 55
invalid-argument-type 39 0 58
unresolved-reference 5 91 0
invalid-key 51 0 0
unsupported-operator 19 0 19
unused-type-ignore-comment 1 33 0
invalid-assignment 6 4 6
division-by-zero 0 14 0
not-subscriptable 14 0 0
no-matching-overload 8 1 0
invalid-declaration 5 0 0
invalid-return-type 1 0 4
not-iterable 1 0 3
possibly-missing-attribute 4 0 0
call-non-callable 1 0 0
too-many-positional-arguments 1 0 0
type-assertion-failure 0 0 1
Total 538 144 146

Full report with detailed diff (timing results)

@oconnor663 oconnor663 force-pushed the jack/cyclic_control_flow branch from 962ec70 to a02fdff Compare January 29, 2026 22:34
@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 29, 2026

mypy_primer results

Changes were detected when running on open source projects
attrs (https://github.com/python-attrs/attrs)
+ src/attr/_make.py:476:36: error[unresolved-attribute] Attribute `default` is not defined on `Attribute` in union `Attribute | Unknown`
- Found 638 diagnostics
+ Found 639 diagnostics

anyio (https://github.com/agronholm/anyio)
+ src/anyio/_backends/_asyncio.py:822:34: error[unresolved-attribute] Attribute `__context__` is not defined on `None` in union `BaseException | None`
+ src/anyio/_backends/_asyncio.py:823:25: error[unresolved-attribute] Attribute `__context__` is not defined on `None` in union `BaseException | None`
- Found 88 diagnostics
+ Found 90 diagnostics

parso (https://github.com/davidhalter/parso)
+ parso/python/tokenize.py:426:24: warning[possibly-unresolved-reference] Name `endprog` used when possibly not defined
+ parso/python/tokenize.py:431:21: warning[possibly-unresolved-reference] Name `contstr_start` used when possibly not defined
+ parso/python/tokenize.py:436:28: warning[possibly-unresolved-reference] Name `contline` used when possibly not defined
+ parso/tree.py:89:17: error[unresolved-attribute] Attribute `parent` is not defined on `None` in union `Self@get_previous_leaf | BaseNode | None`
+ parso/tree.py:92:24: error[unresolved-attribute] Attribute `parent` is not defined on `None` in union `Self@get_previous_leaf | BaseNode | None`
+ parso/tree.py:115:17: error[unresolved-attribute] Attribute `parent` is not defined on `None` in union `Self@get_next_leaf | BaseNode | None`
+ parso/tree.py:118:24: error[unresolved-attribute] Attribute `parent` is not defined on `None` in union `Self@get_next_leaf | BaseNode | None`
- Found 159 diagnostics
+ Found 166 diagnostics

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 `Unknown | Sized`
+ 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: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: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:139:27: error[unsupported-operator] Operator `+` is not supported between objects of type `Unknown | Sized` and `LiteralString`
+ src/pip/_internal/req/req_uninstall.py:139:27: error[unsupported-operator] Operator `+` is not supported between objects of type `Sized | Unknown` and `LiteralString`

spack (https://github.com/spack/spack)
- lib/spack/spack/cmd/url.py:240:40: warning[division-by-zero] Cannot divide object of type `Literal[0]` by zero
- lib/spack/spack/cmd/url.py:240:40: warning[division-by-zero] Cannot divide object of type `Literal[1]` by zero
- lib/spack/spack/cmd/url.py:245:43: warning[division-by-zero] Cannot divide object of type `Literal[0]` by zero
- lib/spack/spack/cmd/url.py:245:43: warning[division-by-zero] Cannot divide object of type `Literal[1]` by zero
- lib/spack/spack/config.py:1481:61: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- lib/spack/spack/config.py:1726:18: error[invalid-argument-type] Argument to function `validate` is incorrect: Expected `dict[str, Any]`, found `None | dict[Unknown | str, Unknown | None]`
+ lib/spack/spack/config.py:1726:18: error[invalid-argument-type] Argument to function `validate` is incorrect: Expected `dict[str, Any]`, found `None | dict[Unknown | str, Divergent]`
- 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: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:1674:25: error[invalid-argument-type] Argument to function `move` is incorrect: Expected `str | PathLike[str]`, 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/vendor/pyrsistent/_plist.py:103:34: error[unresolved-attribute] Object of type `Self@reverse & ~AlwaysFalsy` has no attribute `first`
- lib/spack/spack/vendor/pyrsistent/_plist.py:104:20: error[unresolved-attribute] Object of type `Self@reverse & ~AlwaysFalsy` has no attribute `rest`
- lib/spack/spack/vendor/pyrsistent/_plist.py:121:28: error[unresolved-attribute] Object of type `Self@split & ~AlwaysFalsy` has no attribute `first`
- lib/spack/spack/vendor/pyrsistent/_plist.py:122:26: error[unresolved-attribute] Object of type `Self@split & ~AlwaysFalsy` has no attribute `rest`
- lib/spack/spack/vendor/pyrsistent/_plist.py:134:19: error[unresolved-attribute] Object of type `Self@__iter__ & ~AlwaysFalsy` has no attribute `first`
- lib/spack/spack/vendor/pyrsistent/_plist.py:135:18: error[unresolved-attribute] Object of type `Self@__iter__ & ~AlwaysFalsy` has no attribute `rest`
- lib/spack/spack/vendor/pyrsistent/_plist.py:155:20: error[unresolved-attribute] Object of type `Self@__eq__ & ~AlwaysFalsy` has no attribute `first`
- lib/spack/spack/vendor/pyrsistent/_plist.py:157:25: error[unresolved-attribute] Object of type `Self@__eq__ & ~AlwaysFalsy` has no attribute `rest`
+ lib/spack/spack/vendor/pyrsistent/_plist.py:103:34: error[unresolved-attribute] Attribute `first` is not defined on `Self@reverse & ~AlwaysFalsy` in union `(Self@reverse & ~AlwaysFalsy) | Divergent`
+ lib/spack/spack/vendor/pyrsistent/_plist.py:104:20: error[unresolved-attribute] Attribute `rest` is not defined on `Self@reverse & ~AlwaysFalsy` in union `(Self@reverse & ~AlwaysFalsy) | Divergent`
+ lib/spack/spack/vendor/pyrsistent/_plist.py:121:28: error[unresolved-attribute] Attribute `first` is not defined on `Self@split & ~AlwaysFalsy` in union `(Self@split & ~AlwaysFalsy) | Divergent`
+ lib/spack/spack/vendor/pyrsistent/_plist.py:122:26: error[unresolved-attribute] Attribute `rest` is not defined on `Self@split & ~AlwaysFalsy` in union `(Self@split & ~AlwaysFalsy) | Divergent`
+ lib/spack/spack/vendor/pyrsistent/_plist.py:134:19: error[unresolved-attribute] Attribute `first` is not defined on `Self@__iter__ & ~AlwaysFalsy` in union `(Self@__iter__ & ~AlwaysFalsy) | Divergent`
+ lib/spack/spack/vendor/pyrsistent/_plist.py:135:18: error[unresolved-attribute] Attribute `rest` is not defined on `Self@__iter__ & ~AlwaysFalsy` in union `(Self@__iter__ & ~AlwaysFalsy) | Divergent`
+ lib/spack/spack/vendor/pyrsistent/_plist.py:155:20: error[unresolved-attribute] Attribute `first` is not defined on `Self@__eq__ & ~AlwaysFalsy` in union `(Self@__eq__ & ~AlwaysFalsy) | Divergent`
+ lib/spack/spack/vendor/pyrsistent/_plist.py:157:25: error[unresolved-attribute] Attribute `rest` is not defined on `Self@__eq__ & ~AlwaysFalsy` in union `(Self@__eq__ & ~AlwaysFalsy) | Divergent`
- lib/spack/spack/vendor/pyrsistent/_plist.py:191:20: error[unresolved-attribute] Object of type `Self@_drop` has no attribute `rest`
+ lib/spack/spack/vendor/pyrsistent/_plist.py:191:20: error[unresolved-attribute] Attribute `rest` is not defined on `Self@_drop` in union `Self@_drop | Divergent`
- lib/spack/spack/vendor/pyrsistent/_plist.py:213:16: error[unresolved-attribute] Object of type `Self@remove & ~AlwaysFalsy` has no attribute `first`
- lib/spack/spack/vendor/pyrsistent/_plist.py:214:45: error[unresolved-attribute] Object of type `Self@remove & ~AlwaysFalsy` has no attribute `rest`
- lib/spack/spack/vendor/pyrsistent/_plist.py:216:33: error[unresolved-attribute] Object of type `Self@remove & ~AlwaysFalsy` has no attribute `first`
- lib/spack/spack/vendor/pyrsistent/_plist.py:217:20: error[unresolved-attribute] Object of type `Self@remove & ~AlwaysFalsy` has no attribute `rest`
+ lib/spack/spack/vendor/pyrsistent/_plist.py:213:16: error[unresolved-attribute] Attribute `first` is not defined on `Self@remove & ~AlwaysFalsy` in union `(Self@remove & ~AlwaysFalsy) | Divergent`
+ lib/spack/spack/vendor/pyrsistent/_plist.py:214:45: error[unresolved-attribute] Attribute `rest` is not defined on `Self@remove & ~AlwaysFalsy` in union `(Self@remove & ~AlwaysFalsy) | Divergent`
+ lib/spack/spack/vendor/pyrsistent/_plist.py:216:33: error[unresolved-attribute] Attribute `first` is not defined on `Self@remove & ~AlwaysFalsy` in union `(Self@remove & ~AlwaysFalsy) | Divergent`
+ lib/spack/spack/vendor/pyrsistent/_plist.py:217:20: error[unresolved-attribute] Attribute `rest` is not defined on `Self@remove & ~AlwaysFalsy` in union `(Self@remove & ~AlwaysFalsy) | Divergent`
- lib/spack/spack/vendor/ruamel/yaml/emitter.py:1681:53: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ lib/spack/spack/vendor/ruamel/yaml/scanner.py:2393:21: error[unresolved-attribute] Attribute `add_full_line_comment` is not defined on `None` in union `Unknown | None | ScannedComments`
+ lib/spack/spack/vendor/ruamel/yaml/scanner.py:2393:66: error[unresolved-attribute] Attribute `column` is not defined on `None` in union `None | Unknown`
+ lib/spack/spack/vendor/ruamel/yaml/scanner.py:2393:79: error[unresolved-attribute] Attribute `line` is not defined on `None` in union `None | Unknown`
- Found 4384 diagnostics
+ Found 4381 diagnostics

jinja (https://github.com/pallets/jinja)
+ docs/examples/inline_gettext_extension.py:57:60: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `None`
+ docs/examples/inline_gettext_extension.py:59:58: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `None`
+ docs/examples/inline_gettext_extension.py:68:17: warning[possibly-unresolved-reference] Name `token` used when possibly not defined
- Found 179 diagnostics
+ Found 182 diagnostics

werkzeug (https://github.com/pallets/werkzeug)
- src/werkzeug/formparser.py:388:21: error[unresolved-reference] Name `_write` used when not defined
+ src/werkzeug/formparser.py:388:21: warning[possibly-unresolved-reference] Name `_write` used when possibly not defined
- src/werkzeug/formparser.py:390:39: error[unresolved-reference] Name `current_part` used when not defined
+ src/werkzeug/formparser.py:390:39: warning[possibly-unresolved-reference] Name `current_part` used when possibly not defined
- src/werkzeug/formparser.py:391:46: error[unresolved-reference] Name `container` used when not defined
+ src/werkzeug/formparser.py:391:46: warning[possibly-unresolved-reference] Name `container` used when possibly not defined
- src/werkzeug/formparser.py:392:55: error[unresolved-reference] Name `current_part` used when not defined
+ src/werkzeug/formparser.py:392:55: warning[possibly-unresolved-reference] Name `current_part` used when possibly not defined
- src/werkzeug/formparser.py:394:44: error[unresolved-reference] Name `current_part` used when not defined
+ src/werkzeug/formparser.py:394:44: warning[possibly-unresolved-reference] Name `current_part` used when possibly not defined
- src/werkzeug/formparser.py:396:61: error[unresolved-reference] Name `container` used when not defined
+ src/werkzeug/formparser.py:396:61: warning[possibly-unresolved-reference] Name `container` used when possibly not defined
- src/werkzeug/formparser.py:400:37: error[unresolved-reference] Name `current_part` used when not defined
+ src/werkzeug/formparser.py:400:37: warning[possibly-unresolved-reference] Name `current_part` used when possibly not defined
- src/werkzeug/formparser.py:403:41: error[unresolved-reference] Name `current_part` used when not defined
+ src/werkzeug/formparser.py:403:41: warning[possibly-unresolved-reference] Name `current_part` used when possibly not defined
- src/werkzeug/formparser.py:404:41: error[unresolved-reference] Name `current_part` used when not defined
+ src/werkzeug/formparser.py:404:41: warning[possibly-unresolved-reference] Name `current_part` used when possibly not defined
- src/werkzeug/formparser.py:405:49: error[unresolved-reference] Name `current_part` used when not defined
+ src/werkzeug/formparser.py:405:49: warning[possibly-unresolved-reference] Name `current_part` used when possibly not defined

pytest (https://github.com/pytest-dev/pytest)
- src/_pytest/assertion/rewrite.py:1011:47: error[unresolved-reference] Name `cond` used when not defined
+ src/_pytest/assertion/rewrite.py:1011:47: warning[possibly-unresolved-reference] Name `cond` used when possibly not defined

aiortc (https://github.com/aiortc/aiortc)
+ src/aiortc/codecs/h264.py:202:20: error[invalid-return-type] Return type does not match returned value: expected `tuple[bytes, bytes]`, found `tuple[bytes, bytes | None]`
- src/aiortc/jitterbuffer.py:81:69: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- src/aiortc/rate.py:498:15: error[unsupported-operator] Operator `<` is not supported between objects of type `int | None` and `Unknown | int`
+ src/aiortc/rate.py:498:15: error[unsupported-operator] Operator `<` is not supported between objects of type `int | None | Unknown` and `Unknown | int`
+ src/aiortc/rtcsctptransport.py:542:31: warning[possibly-unresolved-reference] Name `expected_tsn` used when possibly not defined
+ src/aiortc/rtcsctptransport.py:543:20: warning[possibly-unresolved-reference] Name `ordered` used when possibly not defined
+ src/aiortc/rtcsctptransport.py:557:20: warning[possibly-unresolved-reference] Name `ordered` used when possibly not defined
+ src/aiortc/rtcsctptransport.py:564:41: warning[possibly-unresolved-reference] Name `expected_tsn` used when possibly not defined
- Found 188 diagnostics
+ Found 192 diagnostics

starlette (https://github.com/encode/starlette)
+ starlette/middleware/wsgi.py:110:23: error[unresolved-attribute] Object of type `type[BrokenWorkerInterpreter]` has no attribute `run_sync`
- Found 190 diagnostics
+ Found 191 diagnostics

scrapy (https://github.com/scrapy/scrapy)
+ docs/utils/linkfix.py:54:52: error[invalid-argument-type] Argument to bound method `write_text` is incorrect: Expected `str`, found `None | str`
- Found 1780 diagnostics
+ Found 1781 diagnostics

graphql-core (https://github.com/graphql-python/graphql-core)
+ src/graphql/execution/execute.py:1772:53: error[unresolved-attribute] Object of type `object` has no attribute `errors`
+ src/graphql/language/visitor.py:216:33: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Iterable[Unknown]`, found `None | Any | Node | tuple[Unknown, ...]`
+ src/graphql/language/visitor.py:219:37: error[unsupported-operator] Operator `-` is not supported between objects of type `Any | int | str` and `int`
+ src/graphql/language/visitor.py:228:60: error[unresolved-attribute] Attribute `keys` is not defined on `None`, `tuple[Unknown, ...]` in union `None | Any | Node | tuple[Unknown, ...]`
+ src/graphql/language/visitor.py:230:19: error[unresolved-attribute] Attribute `idx` is not defined on `None` in union `None | Stack`
+ src/graphql/language/visitor.py:231:20: error[unresolved-attribute] Attribute `keys` is not defined on `None` in union `None | Stack`
+ src/graphql/language/visitor.py:232:21: error[unresolved-attribute] Attribute `edits` is not defined on `None` in union `None | Stack`
+ src/graphql/language/visitor.py:233:24: error[unresolved-attribute] Attribute `in_array` is not defined on `None` in union `None | Stack`
+ src/graphql/language/visitor.py:234:21: error[unresolved-attribute] Attribute `prev` is not defined on `None` in union `None | Stack`
+ src/graphql/language/visitor.py:238:24: error[not-subscriptable] Cannot subscript object of type `Node` with no `__getitem__` method
+ src/graphql/language/visitor.py:241:24: error[no-matching-overload] No overload of function `getattr` matches arguments
+ src/graphql/language/visitor.py:266:34: error[invalid-argument-type] Argument to bound method `append` is incorrect: Expected `tuple[int | str, Node]`, found `tuple[None | Any | int | Node, @Todo & ~Literal[VisitorActionEnum.BREAK] & ~Literal[True] & ~Literal[VisitorActionEnum.SKIP] & ~Literal[False] & ~None]`
+ 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:283:55: error[invalid-argument-type] Argument is incorrect: Expected `Stack`, found `None`
+ src/graphql/language/visitor.py:283:55: error[invalid-argument-type] Argument is incorrect: Expected `Stack`, found `None | Stack`
- Found 637 diagnostics
+ Found 650 diagnostics

pylint (https://github.com/pycqa/pylint)
- 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`

alerta (https://github.com/alerta/alerta)
+ alerta/utils/api.py:123:48: error[invalid-assignment] Object of type `Unknown | None | Any | (tuple[Divergent, Divergent, Divergent, Divergent] & Alert) | (tuple[Divergent, str | Unknown, str | Unknown, int | Unknown] & Alert)` is not assignable to `Alert`
+ alerta/utils/api.py:125:17: error[invalid-assignment] Too many values to unpack: Expected 3
+ alerta/utils/api.py:125:17: error[invalid-assignment] Too many values to unpack: Expected 3
- Found 624 diagnostics
+ Found 627 diagnostics

ignite (https://github.com/pytorch/ignite)
+ tests/ignite/handlers/test_param_scheduler.py:484:21: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/ignite/handlers/test_param_scheduler.py:554:21: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/ignite/handlers/test_param_scheduler.py:627:21: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ tests/ignite/handlers/test_param_scheduler.py:1121:29: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- Found 2136 diagnostics
+ Found 2140 diagnostics

beartype (https://github.com/beartype/beartype)
- beartype/claw/_ast/_kind/clawastimport.py:622:68: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- beartype/claw/_ast/_kind/clawastimport.py:631:72: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- beartype/claw/_ast/_kind/clawastimport.py:1333:81: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 518 diagnostics
+ Found 515 diagnostics

PyGithub (https://github.com/PyGithub/PyGithub)
+ tests/Organization.py:875:37: warning[possibly-unresolved-reference] Name `repo_config` used when possibly not defined
- Found 324 diagnostics
+ Found 325 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 24 diagnostics
+ Found 25 diagnostics

pylox (https://github.com/sco1/pylox)
- pylox/environment.py:26:34: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 47 diagnostics
+ Found 46 diagnostics

poetry (https://github.com/python-poetry/poetry)
+ src/poetry/console/logging/io_formatter.py:67:22: warning[possibly-unresolved-reference] Name `p` used when possibly not defined
+ src/poetry/mixology/version_solver.py:368:67: error[invalid-argument-type] Argument to bound method `difference` is incorrect: Expected `Term`, found `None | Term`
- Found 976 diagnostics
+ Found 978 diagnostics

dragonchain (https://github.com/dragonchain/dragonchain)
- dragonchain/job_processor/contract_job.py:167:24: error[unresolved-attribute] Attribute `split` is not defined on `None` in union `Unknown | None | (Divergent & ~AlwaysFalsy)`
+ dragonchain/job_processor/contract_job.py:167:24: error[unresolved-attribute] Attribute `split` is not defined on `None` in union `Unknown | None`
- dragonchain/job_processor/contract_job.py:198:60: error[not-iterable] Object of type `Unknown | None | (Divergent & ~AlwaysFalsy)` may not be iterable
+ dragonchain/job_processor/contract_job.py:198:60: error[not-iterable] Object of type `Unknown | None` may not be iterable
- dragonchain/job_processor/contract_job.py:250:29: error[invalid-argument-type] Argument to bound method `pull_image` is incorrect: Expected `str`, found `Unknown | None | (Divergent & ~AlwaysFalsy)`
+ dragonchain/job_processor/contract_job.py:250:29: error[invalid-argument-type] Argument to bound method `pull_image` is incorrect: Expected `str`, found `Unknown | None`
- dragonchain/job_processor/contract_job.py:327:23: error[not-iterable] Object of type `Unknown | None | (Divergent & ~AlwaysFalsy)` may not be iterable
+ dragonchain/job_processor/contract_job.py:327:23: error[not-iterable] Object of type `Unknown | None` may not be iterable
- dragonchain/job_processor/contract_job.py:419:13: error[unresolved-attribute] Attribute `update` is not defined on `None` in union `Unknown | None | (Divergent & ~AlwaysFalsy)`
+ dragonchain/job_processor/contract_job.py:419:13: error[unresolved-attribute] Attribute `update` is not defined on `None` in union `Unknown | None`

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 3153 diagnostics
+ Found 3204 diagnostics

optuna (https://github.com/optuna/optuna)
+ optuna/_hypervolume/hssp.py:137:82: error[invalid-argument-type] Argument to function `_lazy_contribs_update` is incorrect: Expected `int | float`, found `Any | ndarray[Unknown, Unknown]`
- optuna/storages/_rdb/alembic/versions/v3.0.0.c.py:128:25: error[invalid-assignment] Object of type `(Unknown & ~None) | Column[int | float]` is not assignable to `int | float`
+ optuna/storages/_rdb/alembic/versions/v3.0.0.c.py:116:13: error[invalid-declaration] Cannot declare type `int | float` for inferred type `float | (Unknown & ~None) | Column[int | float]`
+ optuna/storages/_rdb/alembic/versions/v3.0.0.c.py:132:74: error[invalid-argument-type] Argument to bound method `intermediate_value_to_stored_repr` is incorrect: Expected `int | float`, found `float | (Unknown & ~None) | Column[int | float]`
- optuna/storages/_rdb/alembic/versions/v3.0.0.d.py:132:25: error[invalid-assignment] Object of type `Unknown | Column[int | float]` is not assignable to `int | float`
+ optuna/storages/_rdb/alembic/versions/v3.0.0.d.py:126:13: error[invalid-declaration] Cannot declare type `int | float` for inferred type `float | Unknown | Column[int | float]`
+ optuna/storages/_rdb/alembic/versions/v3.0.0.d.py:137:54: error[invalid-argument-type] Argument to bound method `value_to_stored_repr` is incorrect: Expected `int | float`, found `float | Unknown | Column[int | float]`
- Found 570 diagnostics
+ Found 573 diagnostics

urllib3 (https://github.com/urllib3/urllib3)
+ src/urllib3/http2/connection.py:263:21: warning[possibly-unresolved-reference] Name `headers` used when possibly not defined
- test/test_response.py:1046:45: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive

mitmproxy (https://github.com/mitmproxy/mitmproxy)
+ mitmproxy/addons/cut.py:51:28: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
- mitmproxy/addons/cut.py:57:24: error[unresolved-attribute] Object of type `Flow & ~AlwaysFalsy` has no attribute `headers`
+ mitmproxy/addons/cut.py:53:28: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ mitmproxy/addons/cut.py:57:24: error[unresolved-attribute] Attribute `headers` is not defined on `Flow & ~AlwaysFalsy` in union `(Flow & ~AlwaysFalsy) | (Any & ~AlwaysFalsy)`
- test/mitmproxy/proxy/tutils.py:262:41: error[unresolved-attribute] Object of type `Command | Event` has no attribute `name`
+ test/mitmproxy/proxy/tutils.py:262:41: error[unresolved-attribute] Attribute `name` is not defined on `Command`, `Event` in union `Command | Event | Unknown`
- Found 2127 diagnostics
+ Found 2129 diagnostics

mypy (https://github.com/python/mypy)
+ mypy/semanal_main.py:218:20: warning[possibly-unresolved-reference] Name `state` used when possibly not defined
+ mypy/semanal_main.py:219:40: warning[possibly-unresolved-reference] Name `state` used when possibly not defined
+ mypy/semanal_main.py:219:52: warning[possibly-unresolved-reference] Name `state` used when possibly not defined
+ mypy/semanal_main.py:224:13: warning[possibly-unresolved-reference] Name `state` used when possibly not defined
- Found 1725 diagnostics
+ Found 1729 diagnostics

psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/_cursor_base.py:236:17: warning[possibly-unresolved-reference] Name `pgq` used when possibly not defined
+ psycopg/psycopg/_cursor_base.py:238:48: warning[possibly-unresolved-reference] Name `pgq` used when possibly not defined
+ psycopg/psycopg/_cursor_base.py:268:17: warning[possibly-unresolved-reference] Name `pgq` used when possibly not defined
+ psycopg/psycopg/_cursor_base.py:270:48: warning[possibly-unresolved-reference] Name `pgq` used when possibly not defined
- Found 651 diagnostics
+ Found 655 diagnostics

comtypes (https://github.com/enthought/comtypes)
- comtypes/tools/codegenerator/packing.py:58:43: error[unresolved-reference] Name `details` used when not defined
+ comtypes/tools/codegenerator/packing.py:58:43: warning[possibly-unresolved-reference] Name `details` used when possibly not defined

speedrun.com_global_scoreboard_webapp (https://github.com/Avasam/speedrun.com_global_scoreboard_webapp)
- backend/services/user_updater_helpers.py:143:27: warning[division-by-zero] Cannot divide object of type `float` by zero
- Found 21 diagnostics
+ Found 20 diagnostics

freqtrade (https://github.com/freqtrade/freqtrade)
+ freqtrade/rpc/telegram.py:672:59: warning[possibly-unresolved-reference] Name `first_avg` used when possibly not defined
+ freqtrade/rpc/telegram.py:672:72: warning[possibly-unresolved-reference] Name `first_avg` used when possibly not defined
- Found 653 diagnostics
+ Found 655 diagnostics

cibuildwheel (https://github.com/pypa/cibuildwheel)
+ cibuildwheel/platforms/macos.py:575:17: error[invalid-declaration] Cannot declare type `list[Literal["x86_64", "arm64"]]` for inferred type `list[Unknown | str]`
- Found 27 diagnostics
+ Found 28 diagnostics

discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/core.py:813:44: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- discord/ext/commands/core.py:814:39: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- discord/ext/commands/core.py:831:44: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- discord/ext/commands/core.py:832:39: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- discord/ext/commands/core.py:1495:47: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 532 diagnostics
+ Found 527 diagnostics

vision (https://github.com/pytorch/vision)
- references/depth/stereo/transforms.py:190:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[tuple[Unknown, Unknown], tuple[Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None, Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None], tuple[Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None, Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None]]`, found `tuple[tuple[Unknown, Unknown], tuple[Unknown, ...] | tuple[None, ...], tuple[Unknown, ...] | tuple[None, ...]]`
+ references/depth/stereo/transforms.py:190:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[tuple[Unknown, Unknown], tuple[Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None, Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None], tuple[Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None, Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None]]`, found `tuple[tuple[Unknown, Unknown], tuple[Unknown, ...] | tuple[None, ...] | Unknown, tuple[Unknown, ...] | tuple[None, ...] | Unknown]`
- references/depth/stereo/transforms.py:485:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[tuple[Unknown, Unknown], tuple[Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None, Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None], tuple[Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None, Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None]]`, found `tuple[tuple[Unknown, ...], tuple[Unknown, ...] | tuple[None, ...], tuple[Unknown, ...] | tuple[None, ...]]`
+ references/depth/stereo/transforms.py:485:16: error[invalid-return-type] Return type does not match returned value: expected `tuple[tuple[Unknown, Unknown], tuple[Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None, Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None], tuple[Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None, Unknown | ndarray[tuple[Any, ...], dtype[Any]] | None]]`, found `tuple[tuple[Unknown, ...], tuple[None, ...] | Unknown, tuple[None, ...] | Unknown]`
- references/optical_flow/train.py:178:48: error[unresolved-reference] Name `val_dataset` used when not defined
+ references/optical_flow/train.py:178:48: warning[possibly-unresolved-reference] Name `val_dataset` used when possibly not defined
+ torchvision/datasets/_stereo_matching.py:542:17: error[unsupported-operator] Operator `+=` is not supported between objects of type `list[tuple[None, None]]` and `list[tuple[str, str | None]]`
+ torchvision/datasets/widerface.py:144:45: warning[possibly-unresolved-reference] Name `img_path` used when possibly not defined
- Found 1436 diagnostics
+ Found 1438 diagnostics

pyodide (https://github.com/pyodide/pyodide)
+ pyodide-build/pyodide_build/pywasmcross.py:344:9: warning[possibly-unresolved-reference] Name `symbol_lines` used when possibly not defined
+ pyodide-build/pyodide_build/pywasmcross.py:351:16: warning[possibly-unresolved-reference] Name `export` used when possibly not defined
+ pyodide-build/pyodide_build/pywasmcross.py:352:24: warning[possibly-unresolved-reference] Name `name` used when possibly not defined
+ pyodide-build/pyodide_build/pywasmcross.py:354:68: warning[possibly-unresolved-reference] Name `symbol_lines` used when possibly not defined
+ pyodide-build/pyodide_build/pywasmcross.py:356:31: warning[possibly-unresolved-reference] Name `name` used when possibly not defined
- Found 936 diagnostics
+ Found 941 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 470 diagnostics
+ Found 471 diagnostics

cloud-init (https://github.com/canonical/cloud-init)
- cloudinit/sources/DataSourceScaleway.py:149:11: error[unresolved-reference] Name `last_exc` used when not defined
+ cloudinit/sources/DataSourceScaleway.py:149:11: warning[possibly-unresolved-reference] Name `last_exc` used when possibly not defined
- tests/unittests/distros/test_netconfig.py:1181:28: error[unresolved-reference] Name `key` used when not defined
+ tests/unittests/distros/test_netconfig.py:1181:28: warning[possibly-unresolved-reference] Name `key` used when possibly not defined
- tests/unittests/distros/test_netconfig.py:1182:34: error[unresolved-reference] Name `key` used when not defined
+ tests/unittests/distros/test_netconfig.py:1182:34: warning[possibly-unresolved-reference] Name `key` used when possibly not defined
- tests/unittests/distros/test_netconfig.py:1321:28: error[unresolved-reference] Name `key` used when not defined
+ tests/unittests/distros/test_netconfig.py:1321:28: warning[possibly-unresolved-reference] Name `key` used when possibly not defined
- tests/unittests/distros/test_netconfig.py:1322:34: error[unresolved-reference] Name `key` used when not defined
+ tests/unittests/distros/test_netconfig.py:1322:34: warning[possibly-unresolved-reference] Name `key` used when possibly not defined
- tests/unittests/distros/test_netconfig.py:1461:28: error[unresolved-reference] Name `key` used when not defined
+ tests/unittests/distros/test_netconfig.py:1461:28: warning[possibly-unresolved-reference] Name `key` used when possibly not defined
- tests/unittests/distros/test_netconfig.py:1462:34: error[unresolved-reference] Name `key` used when not defined
+ tests/unittests/distros/test_netconfig.py:1462:34: warning[possibly-unresolved-reference] Name `key` used when possibly not defined
- 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`
- tests/unittests/test_net.py:4910:34: error[unresolved-reference] Name `key` used when not defined
+ tests/unittests/test_net.py:4910:34: warning[possibly-unresolved-reference] Name `key` used when possibly not defined
- tests/unittests/test_net.py:4983:34: error[unresolved-reference] Name `key` used when not defined
+ tests/unittests/test_net.py:4983:34: warning[possibly-unresolved-reference] Name `key` used when possibly not defined

meson (https://github.com/mesonbuild/meson)
- mesonbuild/dependencies/cuda.py:137:76: error[invalid-argument-type] Argument to function `version_compare_many` is incorrect: Expected `str`, found `str | None | Unknown`
+ mesonbuild/dependencies/cuda.py:137:76: error[invalid-argument-type] Argument to function `version_compare_many` is incorrect: Expected `str`, found `Unknown | str | None`
- mesonbuild/mformat.py:347:21: error[unsupported-operator] Operator `+=` is not supported between objects of type `Literal[""]` and `Unknown | str | None`
+ mesonbuild/mformat.py:347:21: error[unsupported-operator] Operator `+=` is not supported between objects of type `str` and `Unknown | str | None`
+ mesonbuild/modules/pkgconfig.py:578:25: error[invalid-declaration] Cannot declare type `str | bool` for inferred type `str | Literal[False] | None`
- mesonbuild/modules/pkgconfig.py:583:43: error[invalid-assignment] Object of type `str | Literal[False] | None` is not assignable to `str | bool`

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`
- manticore/core/smtlib/expression.py:884:21: error[unresolved-attribute] Object of type `Self@underlying_variable & ~ArrayVariable` has no attribute `array`
+ manticore/core/smtlib/expression.py:884:21: error[unresolved-attribute] Attribute `array` is not defined on `Self@underlying_variable & ~ArrayVariable` in union `(Self@underlying_variable & ~ArrayVariable) | Divergent`
- manticore/core/smtlib/expression.py:1293:33: error[unresolved-attribute] Object of type `Array & ~ArrayVariable & ~ArraySlice` has no attribute `index`
- manticore/core/smtlib/expression.py:1294:25: error[unresolved-attribute] Object of type `Array & ~ArrayVariable` has no attribute `array`
+ manticore/core/smtlib/expression.py:1293:33: error[unresolved-attribute] Attribute `index` is not defined on `Array & ~ArrayVariable & ~ArraySlice` in union `(Array & ~ArrayVariable & ~ArraySlice) | Divergent`
+ manticore/core/smtlib/expression.py:1294:25: error[unresolved-attribute] Attribute `array` is not defined on `Array & ~ArrayVariable` in union `(Array & ~ArrayVariable) | Divergent`
- manticore/core/smtlib/solver.py:559:22: error[unsupported-operator] Operator `+` is not supported between objects of type `int | bytes` and `Unknown | int | bytes`
+ manticore/core/smtlib/solver.py:559:22: error[unsupported-operator] Operator `+` is not supported between objects of type `int | bytes | Unknown` and `Unknown | int | bytes`
- manticore/core/smtlib/visitors.py:641:58: error[unsupported-operator] Operator `-` is not supported between two objects of type `None | Unknown`
+ manticore/core/smtlib/visitors.py:641:58: error[unsupported-operator] Operator `-` is not supported between objects of type `None | Unknown` and `None | Unknown`
- Found 11083 diagnostics
+ Found 11085 diagnostics

openlibrary (https://github.com/internetarchive/openlibrary)
+ openlibrary/solr/query_utils.py:192:39: warning[possibly-unresolved-reference] Name `next_word` used when possibly not defined
- Found 1137 diagnostics
+ Found 1138 diagnostics

apprise (https://github.com/caronc/apprise)
+ apprise/plugins/email/base.py:1032:25: error[unsupported-operator] Operator `-` is not supported between objects of type `set[Unknown] | None` and `set[Unknown]`
- Found 3482 diagnostics
+ Found 3483 diagnostics

setuptools (https://github.com/pypa/setuptools)
- setuptools/_vendor/importlib_metadata/__init__.py:131:24: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `None`
+ setuptools/_vendor/importlib_metadata/__init__.py:131:24: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `None | str`

xarray (https://github.com/pydata/xarray)
- xarray/core/indexing.py:578:39: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- xarray/structure/concat.py:901:14: error[unresolved-reference] Name `name` used when not defined
+ xarray/structure/concat.py:901:14: warning[possibly-unresolved-reference] Name `name` used when possibly not defined
- xarray/structure/concat.py:905:34: error[unresolved-reference] Name `name` used when not defined
+ xarray/structure/concat.py:905:34: warning[possibly-unresolved-reference] Name `name` used when possibly not defined
- Found 1710 diagnostics
+ Found 1709 diagnostics

prefect (https://github.com/PrefectHQ/prefect)
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, str | None]`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, str | None]`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, str]`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, str]`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `SecretStr`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `SecretStr`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `list[str] | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `list[str] | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `int | float`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `int | float`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `int | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `int | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `int | float`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `int | float`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `list[str] | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `list[str] | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `list[str] | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `list[str] | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `AzureContainerInstanceCredentials`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `AzureContainerInstanceCredentials`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `bool`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `bool`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `int`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `int | float`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `int | float`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `bool`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 4 union elements`
+ src/integrations/prefect-azure/tests/test_aci_worker.py:104:60: error[invalid-argument-type] Argument is incorrect: Expected `bool`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 5 union elements`
- src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `Literal["INFO", "ERROR", "NONE"]`, found `Unknown | str | dict[Unknown, Unknown] | None | int`
+ src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `Literal["INFO", "ERROR", "NONE"]`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 3 union elements`
- src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, str]`, found `Unknown | str | dict[Unknown, Unknown] | None | int`
+ src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `dict[str, str]`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 3 union elements`
- src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | None | int`
+ src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 3 union elements`
- src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Unknown | str | dict[Unknown, Unknown] | None | int`
+ src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 3 union elements`
- src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | None | int`
+ src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 3 union elements`
- src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | None | int`
+ src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 3 union elements`
- src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `SnowflakeCredentials`, found `Unknown | str | dict[Unknown, Unknown] | None | int`
+ src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `SnowflakeCredentials`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 3 union elements`
- src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `list[dict[str, str]]`, found `Unknown | str | dict[Unknown, Unknown] | None | int`
+ src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `list[dict[str, str]]`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 3 union elements`
- src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `list[str]`, found `Unknown | str | dict[Unknown, Unknown] | None | int`
+ src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `list[str]`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 3 union elements`
- src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | None | int`
+ src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `str | None`, found `Unknown | str | dict[Unknown, Unknown] | ... omitted 3 union elements`
- src/integrations/prefect-snowflake/tests/experimental/test_spcs_worker.py:135:58: error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Unknown | str | dict[Unknown, Unknown] | None | int`
+ src/integrations/prefect-

... (truncated 1158 lines) ...

@oconnor663 oconnor663 force-pushed the jack/cyclic_control_flow branch 2 times, most recently from e663909 to f0701e9 Compare January 30, 2026 08:41
@oconnor663 oconnor663 marked this pull request as ready for review January 30, 2026 08:45
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The changes to Divergent handling in IntersectionType here are related to the test case that begins "We need to avoid oscillating cycles...".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update: I've replaced the changes I was referring to here (Divergent handling in intersections during cycle recovery) with changes to InnerIntersectionBuilder in ‎crates/ty_python_semantic/src/types/builder.rs (Divergent handling in all intersections). Without this change, the new and pretty broad Divergent case in evaluate_expr_compare_op leads to a lot of Signature::todo("Type::Intersection.call") types showing up in output.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can move the Divergent handling back here once I finally land #22469 -- at that point we should just get back an intersection with Divergent from the call, and then that would probably get handled here.

But if we aren't seeing negative effects from moving it into IntersectionBuilder directly, maybe that doesn't matter much.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0701e9a85

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@oconnor663
Copy link
Contributor Author

oconnor663 commented Jan 30, 2026

Ecosystem dispositions

possibly-unresolved-reference

Previously we analyzed loop bodies as though executing their first pass. That let us correctly analyze situations like this one where something gets initialized if i == 0: .... With this change we conclude that that condition is ambiguous, and whatever get initialized in that if is maybe unintialized.

However, 1) we don't display possibly-unresolved-reference warnings by default, because of exactly this sort of false positive, and 2) Pyright gives the same error here. These might be acceptable.

possibly-missing-attribute

Some of these (for example this one in antidote) are effectively:

class Node:
    def __init__(self, next: Node | None = None):
        self.next = next

node = Node(Node(Node()))
# warning: [possibly-missing-attribute]
while node.next is not None:
    # warning: [possibly-missing-attribute]
    node = node.next

This is a false positive at runtime (node will never actually be None) but a plausible positive in terms of cyclic control flow analysis of the types (the previous loop iteration bound node to Node | None). However, Pyright doesn't error here, maybe because it does a better job of passing along the narrowing constraint from the while condition? I need to look into this one a little more.

Update: This particular case was fixed in e07ecd0 after some painful debugging.

Some other examples of this are true positives, for example this case in dd-trace-py which now warns that "Attribute f_back may be missing on object of type FrameType | None".

In some cases we get a large number of new diagnostics that could've been diagnostics before, but they were hidden behind an if condition that we (incorrectly) inferred to be statically false, like this branch in graphql-core. Now we infer bool for the condition and check the whole branch.

not-subscriptable

These cases seem to be similar to above, code that always deserved a diagnostic but was hidden inside branches that were incorrectly inferred to be unreachable. For example, this "Cannot subscript object of type None with no __getitem__ method" error in scipy or this one in graphql-core.

invalid-argument-type

This case in dd-trace-py minimizes to something like this:

def _(x: int | None):
    y = 0
    while random():
        y += 1
    reveal_type(y)  # previously `Literal[1]`, now `int`
    assert x == y
    reveal_type(x)  # previously `int`, now `int | None`

Unfortunately now that we have the correct type for y, we can no longer narrow x, because we're considering the possibility (clearly not relevant in this example) that x could be a perverse subclass of int that compares == to None. We don't currently have a way to representing the fact that x is specifically int and not a subclass. Pyright has the same problem here, but Mypy manages to narrow x.

invalid-declaration

Here's a case where meson is declaring a variable to be str | bool but then assigning None to it. The previous true positive was "Object of type str | Literal[False] | None is not assignable to str | bool". But now the loopback binding is visible to the declaration (which is not a binding), and we get "Cannot declare type str | bool for inferred type str | Literal[False] | None". The previous error was probably preferable, but the current error is also arguably accurate?

invalid-syntax

This PR initially triggered some false positives for examples like this (minimized from pywin32):

while True:
    global x  # [invalid-syntax] if `x` is already used or bound
    x = 1

We need to avoid treating the loop header binding as a real bindings for the purpose of detecting invalid global and nonlocal statements. Fixed in 159b0c6.

@carljm
Copy link
Contributor

carljm commented Jan 31, 2026

However, Pyright doesn't error here, maybe because it does a better job of passing along the narrowing constraint from the while condition? I need to look into this one a little more.

I'm actually a little bit surprised that our place-based narrowing doesn't handle this?

Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

It's amazing to see this come together! I did a first-pass review.

Comment on lines 1344 to 1350
// A place shouldn't be definitely-unbound when there are visible bindings. The
// initial UNBOUND definition should either get shadowed by those bindings (if
// they're unconditional), or it should have constraints attached to it (if the
// other bindings are conditional). However, there's one exception to that
// intuitive rule: Loop header definitions don't shadow prior bindings, because
// prior bindings are always visible at the start of the first loop iteration.
Some(Truthiness::AlwaysTrue) => Definedness::PossiblyUndefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is unfortunate, as this unreachable!() has definitely caught bugs before. Can we give a clearer explanation of the kind of code that causes us to hit this case? I don't think I quite understand it -- it seems like having unbound be definitely-visible would require that we have a place that is unbound before the loop, and never bound in the loop... in which case it shouldn't have a loop-header binding at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

093392c restores the assert in most cases, and suppresses it only when a loop header bindings are the only bindings visible. I've added a while_loop.md test case with the simplest example of something that panics without this special case:

while True:
    x  # error: [possibly-unresolved-reference]
    x = 1

The issue is that, because the loop condition is statically true, we don't encounter any narrowing conditions before we get to the first use of x. But because of the loop header, we do have a binding. So the general rule "UNBOUND shouldn't be definitely-visible if you have a binding" is violated. Of course this example doesn't run cleanly, it raises an exception at the use of x, but either way we can't panic when we see it.

There are several other examples in our existing tests that hit this panic (with my loop header changes but without this new special case), and some of them even run (if not terminate) without exceptions, but they're pretty esoteric. eq_without_hash.py has this funny loop:

class MaybeEqWhile:
    while ...:
        def __eq__(self, other): ...

Part of the story there is that ... is truthy. Another part is that I think a function definition also acts like a use of that function, because of overload resolution.

Comment on lines 4247 to 4255
let narrowed_ty = if let Some(constraint) = loop_back_binding
.narrowing_predicates
.iter()
.filter_map(|predicate| infer_narrowing_constraint(db, *predicate, place))
.reduce(|acc, constraint| constraint.merge_constraint_and(acc, db))
{
NarrowingConstraint::intersection(binding_ty)
.merge_constraint_and(constraint, db)
.evaluate_constraint_type(db)
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like the constraint merging is something we should have already done in semantic indexing, so that here we just have a single NarrowingConstraint and can use NarrowingConstraint::narrow, like place_from_bindings_impl does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cleaned up in 7094021. @dcreager do you have any advice for how to name this function that I'm calling constraints_iter? It seems like the items of a ConstraintsIterator are "predicates" rather than "constraints". Would it be better for the world if I called this a predicates_iter? Should we rename the whole type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, pyantic and colour_science show up in CodSpeed with this change, but not before. That feels fishy to me. Any chance those are flakey? (I'm going to rebase and see what happens either way.)

@AlexWaygood AlexWaygood removed their request for review February 2, 2026 23:26
@oconnor663 oconnor663 force-pushed the jack/cyclic_control_flow branch 3 times, most recently from 7364f8a to e0648fa Compare February 3, 2026 20:53
@oconnor663
Copy link
Contributor Author

Putting this into Draft while I address feedback, so I stop alerting folks

@oconnor663 oconnor663 marked this pull request as draft February 3, 2026 22:26
@oconnor663 oconnor663 force-pushed the jack/cyclic_control_flow branch from 25b1645 to 25a3596 Compare February 4, 2026 00:57
@oconnor663
Copy link
Contributor Author

oconnor663 commented Feb 5, 2026

I've been chasing the possibly-missing-attribute ecosystem hits, with the following minimized example:

class Node:
    def __init__(self, next: "Node | None" = None):
        self.next: "Node | None" = next

node = Node(Node(Node()))
while node.next is not None:
    node = node.next

That currently gives a false positive "Attribute next may be missing on object of type Node | None" for both uses of node.next. The sequence of events that leads to this is quite complicated. Here's what I think is happening:

  • We get to infer_while_statement in the course of normal typechecking.
  • That calls infer_standalone_expression on the loop condition, then infer_standalone_expression_impl -> infer_expression_types -> infer_expression_types_impl. This call to infer_expression_types_impl ends up becoming our cycle head.
  • Expression inference naturally ends up looking up the type of node, which sees the loopback binding, and infer_loop_header_definition starts doing narrowing. As part of inferring that, infer_narrowing_constraint goes through a few layers to evaluate_expr_compare, which calls infer_expression_types again on the loop condition. That puts us in the (first...) cycle. So far this is pretty much how we'd expect loopback bindings to work in an example like this.
  • The cycle_initial for infer_expression_types_impl winds up at ExpressionInference::cycle_initial, which returns an empty map that's just says that anything you ask it for is Divergent (the "fallback type").
  • Then -- and this is pretty weird but it seems to be what's happening -- as we work our way back up the infer_narrowing_constraint part of the stack, evaluate_expr_compare evaluates the None expression like this: let rhs_ty = inference.expression_type(right);. But inference is the empty map from cycle_initial, and it says that None itself is actually Divergent
  • Having interpreted is not None as is not Divergent, we make our way to evaluate_expr_compare_op, which notes that Divergent is not a singleton, so it doesn't generate a constraint type for it at all.
  • Working all the way back up the stack, still in the first iteration of cycle recovery, we end up with Node | None | Divergent as the type of node.next in the assignment. I can't quite follow where that Divergent comes from; there's a second, nested cycle head involved. In any case, that Divergent ends up getting eliminated by UnionType::recursive_type_normalized_impl, but there's no constraint to eliminate the None, so we get Node | None as the first cycle iteration's view of the RHS of the assignment.
  • The second cycle iteration manages to resolve ~None properly and correctly narrows node.next to Node. But because of our strategy to avoid oscillations, that gets unioned with Node | None from the previous iteration in Type::cycle_normalized. That gives us Node | None again, and the cycle is resolved (incorrectly).

I'm curious if this sounds plausible to other folks. Not yet sure where we want to intervene here...

Update: This was fixed in e07ecd0.

@oconnor663 oconnor663 force-pushed the jack/cyclic_control_flow branch from fb7b575 to 8901fe9 Compare February 10, 2026 03:03
@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 10, 2026

Memory usage report

Summary

Project Old New Diff Outcome
prefect 678.34MB 693.37MB +2.22% (15.03MB)
sphinx 268.45MB 276.27MB +2.91% (7.82MB)
trio 117.82MB 120.51MB +2.28% (2.68MB)
flake8 49.34MB 49.69MB +0.69% (350.87kB)

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
infer_definition_types 82.92MB 86.43MB +4.24% (3.51MB)
infer_expression_types_impl 51.03MB 54.40MB +6.60% (3.37MB)
infer_expression_type_impl 10.37MB 12.69MB +22.45% (2.33MB)
semantic_index 183.14MB 184.44MB +0.71% (1.30MB)
all_narrowing_constraints_for_expression 4.41MB 5.24MB +18.69% (845.10kB)
infer_scope_types_impl 57.32MB 57.89MB +0.99% (583.53kB)
all_negative_narrowing_constraints_for_expression 1.65MB 2.21MB +34.07% (576.09kB)
get_loop_header 0.00B 515.01kB +515.01kB (new)
Definition 20.36MB 20.85MB +2.42% (505.31kB)
Type<'db>::member_lookup_with_policy_ 14.56MB 14.87MB +2.17% (323.75kB)
infer_deferred_types 14.38MB 14.68MB +2.10% (308.79kB)
UnionType 3.41MB 3.58MB +5.23% (182.39kB)
is_redundant_with_impl::interned_arguments 5.41MB 5.52MB +2.16% (119.80kB)
place_by_id 4.66MB 4.77MB +2.34% (111.79kB)
infer_unpack_types 754.11kB 847.50kB +12.38% (93.39kB)
... 49 more

sphinx

Name Old New Diff Outcome
infer_definition_types 23.32MB 25.06MB +7.44% (1.74MB)
infer_expression_types_impl 21.46MB 22.97MB +7.07% (1.52MB)
infer_expression_type_impl 2.23MB 3.41MB +52.65% (1.18MB)
semantic_index 68.31MB 69.44MB +1.66% (1.13MB)
Definition 8.46MB 8.87MB +4.78% (414.38kB)
get_loop_header 0.00B 401.29kB +401.29kB (new)
all_narrowing_constraints_for_expression 1.46MB 1.82MB +24.70% (368.26kB)
all_negative_narrowing_constraints_for_expression 644.39kB 839.40kB +30.26% (195.01kB)
Type<'db>::member_lookup_with_policy_ 6.14MB 6.30MB +2.58% (162.57kB)
UnionType 1.19MB 1.33MB +12.51% (151.89kB)
infer_scope_types_impl 17.44MB 17.58MB +0.76% (135.91kB)
is_redundant_with_impl::interned_arguments 2.01MB 2.13MB +5.63% (116.02kB)
infer_deferred_types 5.82MB 5.89MB +1.18% (70.04kB)
is_redundant_with_impl 1.78MB 1.84MB +3.67% (66.90kB)
LoopToken 0.00B 44.97kB +44.97kB (new)
... 54 more

trio

Name Old New Diff Outcome
infer_expression_types_impl 5.64MB 6.33MB +12.20% (704.20kB)
infer_expression_type_impl 706.11kB 1.28MB +85.51% (603.82kB)
infer_definition_types 7.17MB 7.74MB +7.97% (585.18kB)
semantic_index 32.87MB 33.06MB +0.59% (199.64kB)
all_narrowing_constraints_for_expression 356.74kB 486.51kB +36.38% (129.77kB)
get_loop_header 0.00B 82.12kB +82.12kB (new)
Definition 4.28MB 4.35MB +1.73% (75.56kB)
UnionType 290.34kB 338.34kB +16.53% (48.00kB)
Type<'db>::member_lookup_with_policy_ 1.71MB 1.76MB +2.72% (47.75kB)
infer_scope_types_impl 5.44MB 5.49MB +0.81% (45.32kB)
infer_deferred_types 2.44MB 2.47MB +1.38% (34.39kB)
all_negative_narrowing_constraints_for_expression 113.60kB 147.71kB +30.03% (34.11kB)
is_redundant_with_impl::interned_arguments 524.73kB 557.39kB +6.22% (32.66kB)
is_redundant_with_impl 464.61kB 484.93kB +4.37% (20.32kB)
Type<'db>::member_lookup_with_policy_::interned_arguments 854.45kB 869.98kB +1.82% (15.54kB)
... 36 more

flake8

Name Old New Diff Outcome
infer_definition_types 1.85MB 1.93MB +4.34% (82.10kB)
infer_expression_types_impl 1.06MB 1.13MB +6.29% (68.37kB)
infer_expression_type_impl 119.82kB 164.36kB +37.18% (44.55kB)
semantic_index 15.24MB 15.28MB +0.26% (40.88kB)
Definition 2.13MB 2.15MB +0.80% (17.53kB)
get_loop_header 0.00B 16.17kB +16.17kB (new)
infer_deferred_types 714.72kB 727.66kB +1.81% (12.94kB)
all_narrowing_constraints_for_expression 54.55kB 65.73kB +20.49% (11.18kB)
all_negative_narrowing_constraints_for_expression 26.46kB 35.59kB +34.52% (9.13kB)
Type<'db>::member_lookup_with_policy_ 419.85kB 426.83kB +1.66% (6.98kB)
infer_scope_types_impl 1.08MB 1.09MB +0.55% (6.15kB)
UnionType 106.55kB 112.00kB +5.12% (5.45kB)
is_redundant_with_impl::interned_arguments 150.05kB 154.86kB +3.21% (4.81kB)
cached_protocol_interface 43.56kB 47.82kB +9.79% (4.27kB)
infer_unpack_types 37.54kB 40.31kB +7.40% (2.78kB)
... 26 more

@oconnor663 oconnor663 force-pushed the jack/cyclic_control_flow branch 2 times, most recently from 7094021 to dc23a4a Compare February 10, 2026 23:08
@oconnor663
Copy link
Contributor Author

I'm bringing this PR out of draft for a second round of review. I've addressed all of @carljm's review comments above, and I've been through the ecosystem report and fixed anything that looked like an obvious bug. (See this comment above.)

Some more performance regressions have crept in in the last few commits, which have now all been rebased together. The CodSpeed report on an experiment/throwaway PR (specifically this commit) makes it look like my changes to Divergent handling in intersections has caused the 4-5% regressions in pandas, colour_science, and freqtrade. I haven't dug into exactly why that is yet; I'd be curious to get @carljm's thoughts on whether this set of changes Feels Good first.

@oconnor663 oconnor663 marked this pull request as ready for review February 11, 2026 02:03
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc23a4a2be

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@oconnor663 oconnor663 force-pushed the jack/cyclic_control_flow branch from 08098f4 to 09b740a Compare February 12, 2026 18:01
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

This looks good to me! Great work.

I wonder if we're going to see some interactions with #23109 once you rebase on that? Hopefully nothing too hairy.

/// Infer the type for a loop header definition.
///
/// The loop header sees all bindings that loop-back, either by reaching the end of the loop
/// body or a `continue` statement. This includes bindings from before the loop too, though
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think this might be potentially confusing. Let's say it can include bindings from before the loop (if they reach the end of the loop). Saying it unconditionally almost sounds like we redundantly include pre-loop bindings in the loop header always, which we don't.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can move the Divergent handling back here once I finally land #22469 -- at that point we should just get back an intersection with Divergent from the call, and then that would probably get handled here.

But if we aren't seeing negative effects from moving it into IntersectionBuilder directly, maybe that doesn't matter much.

@oconnor663 oconnor663 force-pushed the jack/cyclic_control_flow branch from 64acc21 to 29e3110 Compare February 13, 2026 07:08
@oconnor663
Copy link
Contributor Author

Only thing I've noticed on rebase is that a few of the small CodSpeed perf hits went away 🤷‍♂️

@oconnor663 oconnor663 merged commit c056ee6 into main Feb 13, 2026
49 of 50 checks passed
@oconnor663 oconnor663 deleted the jack/cyclic_control_flow branch February 13, 2026 07:22
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.

2 participants