Back

ruff #22799

[ty] Rewrite equality-based narrowing logic

by AlexWaygood · Feb 06, 2026 at 19:14 UTC · scan-3457da71d969ad19

Critical Risk (80%)

Get this automatically on every PR

Install the Axiomo GitHub App to get Signals as check runs and PR comments on every pull request.

Install App

Risk Assessment

Risk level: Critical (80%)

Risk Drivers

  • large_diff: Large change: 1105 lines modified
  • missing_tests: Added 894 lines of code but only 0 lines of tests
  • large_addition_no_tests: Large block of added code (859+ consecutive lines) with no test changes
  • api_surface_change: API surface changed in 3 file(s)

Intent

2/5 criteria met

Rewrite equality-based narrowing logic in type inference.

Acceptance Criteria

  • โœ“
    Reduces complexity in types/narrow.rs

    Reduced lines in narrow.rs (+25/-137).

  • โœ“
    Introduces new equality module

    New file src/types/equality.rs added with 859 lines.

  • ?
    Fixes issue #2732

    Issue 2732 mentioned, but no specific references in the diff.

  • ?
    Fixes issue #1454

    Issue 1454 mentioned, but no specific references in the diff.

  • โœ—
    Maintains all existing test behavior

    Tests failing are noted in the PR description.

Confidence: 90.0% Source: pr description AI: openai

Contributors

AlexWaygood PR Author 1 commit + Trusted
Account Age: 2080 days
Prior PRs: 1017
Merged: 907

Trusted contributor with 907 merged PRs. maintains 69 public repositories. has 506 followers. unfamiliar with 4 files being modified.

Evidence

Evidence Completeness: 30.0%
ci_passing Unavailable
build_successful Unavailable
tests_passing Failing
Missing: lint_passing, security_scan_clean, coverage_maintained

Supply Chain

None Risk
Modifies dependencies
Modifies lockfile
Modifies CI config
Modifies build scripts

Focus Files

Focus on 1 critical file(s)

crates/ty_python_semantic/src/types/equality.rs +859

859 lines changed; New file; Source code

critical
crates/ty_python_semantic/src/types/narrow.rs +162

162 lines changed; Source code

high
crates/ty_python_semantic/src/types.rs +12

Source code

medium
crates/ty_python_semantic/src/types/enums.rs +2

Source code

medium
crates/ty_python_semantic/resources/mdtest/narrow/conditionals/eq.md +48

Standard file

low
crates/ty_python_semantic/resources/mdtest/narrow/conditionals/elif_else.md +8

Standard file

low
crates/ty_python_semantic/resources/mdtest/narrow/conditionals/nested.md +8

Standard file

low
crates/ty_python_semantic/resources/mdtest/narrow/match.md +6

Standard file

low

Triage

129

minutes to review

extensive

effort level

none

staleness risk

Schedule dedicated review time; consider pair review

Recommendation

REQUEST CHANGES 43.0% readiness

Critical risk level requires changes before approval

Next Steps

Concern

Consider breaking into smaller PRs

Question

Why is lint_passing missing? Consider adding this check.

Question

Why is security_scan_clean missing? Consider adding this check.

Concern crates/ty_python_semantic/src/types/equality.rs

Critical file: 859 lines changed; New file; Source code