Skip to content

[ty] Add with_recursion_guard() helpers to relation.rs - #23945

Merged
AlexWaygood merged 1 commit into
mainfrom
alex/cleanup-relation-rs
Mar 13, 2026
Merged

AlexWaygood merged 1 commit into
mainfrom
alex/cleanup-relation-rs

Conversation

@AlexWaygood

Copy link
Copy Markdown
Member

Summary

A small followup to #23837 to further improve readability. Rather than repeating self.relation_visitor.visit((source, target, self.relation, || {}) everywhere, add a helper method so that we can call self.with_recursion_guard(source, target, || {}) instead. This ends up being exactly neutral in terms of lines of code added/removed, but I think it makes the big recursive matches in TypeRelationChecker::check_type_pair and DisjointnessChecker::check_type_pair significantly more readable. (And these are two of the most complex and important methods in ty's codebase.)

Test Plan

existing tests

@AlexWaygood AlexWaygood added internal An internal refactor or improvement (not for changelogs) ty The ty type checker labels Mar 13, 2026
@astral-sh-bot

astral-sh-bot Bot commented Mar 13, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 85.29%. The percentage of expected errors that received a diagnostic held steady at 78.13%. The number of fully passing files held steady at 64/132.

@astral-sh-bot

astral-sh-bot Bot commented Mar 13, 2026

Copy link
Copy Markdown

mypy_primer results

Changes were detected when running on open source projects
scikit-build-core (https://github.com/scikit-build/scikit-build-core)
- src/scikit_build_core/build/wheel.py:99:20: error[no-matching-overload] No overload of bound method `__init__` matches arguments
- Found 58 diagnostics
+ Found 57 diagnostics

@astral-sh-bot

astral-sh-bot Bot commented Mar 13, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@AlexWaygood
AlexWaygood merged commit 86f0b43 into main Mar 13, 2026
52 checks passed
@AlexWaygood
AlexWaygood deleted the alex/cleanup-relation-rs branch March 13, 2026 19:03
carljm added a commit that referenced this pull request Mar 16, 2026
* main: (131 commits)
  [ty] Fixup examples in `invalid-key` docs (#23968)
  [ty] Fix compiler warning about unused variable (#23967)
  [ty] Sync vendored typeshed stubs (#23963)
  Add a `.git-blame-ignore-revs` file (#23959)
  Revert "[ty] Completely remove the `NoReturn` shortcut optimization" (#23955)
  [ty] Completely remove the `NoReturn` shortcut optimization (#23378)
  [ty] Introduce fast path for protocol non-assignability (#23952)
  Bump typing conformance suite SHA (#23951)
  Minor followup to severity display - use preview function in server instead of checking preview disabled directly (#23950)
  Document editor features for markdown code formatting (#23924)
  [ty] Add `with_recursion_guard()` helpers to `relation.rs` (#23945)
  [ty] Remove `check_optional_method_pair` methods (#23947)
  [ty] Remove unused `CycleDetector::try_visit` method (#23944)
  [ty] Ensure TypedDict subscripts for unknown keys return Unknown (#23926)
  [ty] Fix variance of frozen dataclass-transform models (#23931)
  Display output severity in preview (#23845)
  Revert "[`ruff`] use `bitcode` instead of `bincode`" (#23935)
  Fix shell injection via `shell=True` in subprocess calls (#23894)
  [ty] Refactor `relation.rs` to store state on a struct rather than passing around 7 arguments every time we recurse (#23837)
  Don't return code actions for non-Python documents (#23905)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement (not for changelogs) ty The ty type checker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants