[ty] Track non-terminal-call constraints in global scope#23245
Merged
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 86.46%. The percentage of expected errors that received a diagnostic held steady at 80.68%. The number of fully passing files held steady at 67/132. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
trio
flake8
|
ReturnsNever constraints in global scope
Merging this PR will not alter performance
Comparing Footnotes
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-await |
0 | 40 | 0 |
invalid-argument-type |
0 | 2 | 0 |
invalid-return-type |
0 | 1 | 0 |
| Total | 0 | 43 | 0 |
Changes in flaky projects detected. Raw diff output excludes flaky projects; see the HTML report for details.
Raw diff:
dd-trace-py (https://github.com/DataDog/dd-trace-py)
- benchmarks/base/run.py:114:45 error[invalid-argument-type] Argument to function `cpu_affinity_to_cpu_groups` is incorrect: Expected `str`, found `str | None`
vision (https://github.com/pytorch/vision)
- .github/process_commit.py:77:47 error[invalid-argument-type] Argument to function `get_pr_merger_and_labels` is incorrect: Expected `int`, found `int | None`
This comment was marked as resolved.
This comment was marked as resolved.
ea28e5e to
856c2b2
Compare
ReturnsNever constraints in global scopeIsNonTerminalCall constraints in global scope
sharkdp
added a commit
that referenced
this pull request
Mar 26, 2026
## Summary
This changes the `many_enum_members` benchmark from this structure:
```py
class E(Enum):
m1 = 1
m2 = 2
...
print(E.m1)
print(E.m2)
...
```
to this structure:
```py
class E(Enum):
m1 = 1
m2 = 2
...
print((E.m1, E.m2, …))
```
The idea here is to make this benchmark less susceptible to changes in
our reachability constraints (that we record for `print` calls). The
idea of the `print` statements was only to have "uses" of these enum
members. It was never the idea to be an example of 512 function calls in
sequence.
I'm certainly not trying to hide the fact that this benchmark revealed a
huge regression in #23245. But it
did so for the wrong reasons. We would have already had that regression
on `main` if those `print` calls would have been inside another function
scope. And so it seems fair to change the benchmark before we proceed
with #23245 (which shows no regressions elsewhere, and even leads to
performance improvements in real world projects).
sharkdp
added a commit
that referenced
this pull request
Mar 26, 2026
## Summary Some mdtest changes in preparation for #23245.
99d7273 to
8d3e3ea
Compare
ee10221 to
3a27f34
Compare
IsNonTerminalCall constraints in global scope
AlexWaygood
approved these changes
Mar 26, 2026
| .record_narrowing_constraint_for_all_places(constraint); | ||
| } else { | ||
| // In non-function scopes, we only record a narrowing constraint | ||
| // (no a reachability constraints). Recording reachability for |
Member
There was a problem hiding this comment.
Suggested change
| // (no a reachability constraints). Recording reachability for | |
| // (not a reachability constraint). Recording reachability for |
Member
There was a problem hiding this comment.
this is marked as resolved but I still see the typos 😆
3a27f34 to
761588f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
preparatory work: #24207 #24203
We previously avoided recording
IsNonTerminalCallcalls in global scope (non-function scopes, to be precise) because we were worried about the performance implications. However, it turns out that this does not cause any slowdowns in our real world ty benchmarks (but see #24203). There is also no dramatic change in the ecosystem timings.closes astral-sh/ty#2480
Ecosystem
Two false positives removed.
Test Plan
Adapted previously existing test