[ty] Use basic blocks for determining if a node is in an if TYPE_CHECKING block#24394
Merged
AlexWaygood merged 2 commits intomainfrom Apr 6, 2026
Merged
[ty] Use basic blocks for determining if a node is in an if TYPE_CHECKING block#24394AlexWaygood merged 2 commits intomainfrom
if TYPE_CHECKING block#24394AlexWaygood merged 2 commits intomainfrom
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 87.72%. The percentage of expected errors that received a diagnostic held steady at 82.85%. The number of fully passing files held steady at 74/132. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
trio
flake8
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
unsupported-operator |
0 | 5 | 0 |
| Total | 0 | 5 | 0 |
Raw diff:
pydantic (https://github.com/pydantic/pydantic)
- pydantic/_internal/_repr.py:18:42 error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'str'>` and `None`
- pydantic/_internal/_repr.py:19:42 error[unsupported-operator] Operator `|` is unsupported between objects of type `<special-form 'typing.Any'>` and `<class 'tuple[Any]'>`
- pydantic/_internal/_utils.py:33:35 error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'Mapping[int, Any]'>` and `<class 'Mapping[str, Any]'>`
- pydantic/_internal/_utils.py:34:36 error[unsupported-operator] Operator `|` is unsupported between objects of type `<class 'AbstractSet[int]'>` and `<class 'AbstractSet[str]'>`
xarray (https://github.com/pydata/xarray)
- xarray/core/dataarray.py:127:52 error[unsupported-operator] Operator `|` is unsupported between objects of type `Literal["DataArray"]` and `<class 'Dataset'>`e6a8ff1 to
dec71e2
Compare
carljm
approved these changes
Apr 4, 2026
| scope_id: FileScopeId, | ||
| range: TextRange, | ||
| ) -> bool { | ||
| self.scope(scope_id).in_type_checking_block() |
Contributor
There was a problem hiding this comment.
Do we still need to separately track per-scope in_type_checking_block?
Member
Author
There was a problem hiding this comment.
No, we don't -- and we don't need to track per-scope reachability either. I'll revive a version of #24392 after this PR lands and expand it to also get rid of the in_type_checking_block field/method from Scope, as well as the reachability field.
Contributor
There was a problem hiding this comment.
No, we don't -- and we don't need to track per-scope reachability either
Curious to see that! I tried to remove per-scope reachability some weeks ago, and it wasn't (easily) possible, if I remember correctly.
This was referenced Apr 27, 2026
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.
Fixes astral-sh/ty#1553