Skip to content

Simplify NewType handling in relation.rs#24109

Merged
AlexWaygood merged 1 commit intomainfrom
alex/newtype-subtype-branches
Mar 23, 2026
Merged

Simplify NewType handling in relation.rs#24109
AlexWaygood merged 1 commit intomainfrom
alex/newtype-subtype-branches

Conversation

@AlexWaygood
Copy link
Copy Markdown
Member

@AlexWaygood AlexWaygood commented Mar 22, 2026

Summary

We currently have two dedicated branches in the big has_relation_to match that are both only there to handle the special case of NewTypes of unions. I believe we can simplify the code a fair bit by consolidating both special cases into the (_, Type::Union(...)) branch of the match.

Test Plan

Existing tests all pass. This branch is based on top of #24113 and #24115, which together improve our NewType test coverage a fair bit.

@AlexWaygood AlexWaygood added internal An internal refactor or improvement ty Multi-file analysis & type inference labels Mar 22, 2026
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Mar 22, 2026

Typing conformance results

No changes detected ✅

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

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Mar 22, 2026

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot bot commented Mar 22, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-await 0 40 0
invalid-return-type 0 1 0
Total 0 41 0

Changes in flaky projects detected. Raw diff output excludes flaky projects; see the HTML report for details.

Full report with detailed diff (timing results)

@AlexWaygood AlexWaygood force-pushed the alex/newtype-subtype-branches branch 4 times, most recently from b95484f to 5cdd2cf Compare March 22, 2026 22:06
@AlexWaygood AlexWaygood force-pushed the alex/newtype-subtype-branches branch from 5cdd2cf to c7d8798 Compare March 22, 2026 22:10
@AlexWaygood AlexWaygood changed the base branch from main to alex/more-newtype-tests March 22, 2026 22:10
@AlexWaygood AlexWaygood reopened this Mar 22, 2026
@AlexWaygood AlexWaygood marked this pull request as ready for review March 22, 2026 22:13
Copy link
Copy Markdown
Contributor

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you

@AlexWaygood AlexWaygood force-pushed the alex/more-newtype-tests branch from a702e2d to 2c49c6e Compare March 23, 2026 12:20
Base automatically changed from alex/more-newtype-tests to main March 23, 2026 12:24
@AlexWaygood AlexWaygood force-pushed the alex/newtype-subtype-branches branch from c7d8798 to 3db2760 Compare March 23, 2026 12:25
@AlexWaygood AlexWaygood merged commit 6a9bd4e into main Mar 23, 2026
48 checks passed
@AlexWaygood AlexWaygood deleted the alex/newtype-subtype-branches branch March 23, 2026 12:32
carljm added a commit that referenced this pull request Mar 25, 2026
* main: (36 commits)
  [ty] Reduce diagnostic range for `invalid-metaclass` (#24145)
  [ty] Simplify TypeVar assignability/subtyping logic (#24138)
  [ty] Prevent tainted loop bindings in cycle normalization (#24143)
  [ty] Add precisely-typed overloads for `TypedDict` update (#24101)
  [ty] Fix folding ranges of comments separated by statements (#24132)
  Bump ecosystem-analyzer pin (#24136)
  Bump ecosystem-analyzer pin (#24135)
  Simplify `NewType` handling in `relation.rs` (#24109)
  [ty] Add more tests for `NewType` subtyping (#24115)
  [ty] Add `NewType`s to the property tests (#24113)
  [ty] Prepare test files for unreachable code change (#24133)
  `analyze graph`: resolve string imports that reference attributes, not just modules (#24058)
  Update Artifact GitHub Actions dependencies (#24116)
  Update taiki-e/install-action action to v2.68.33 (#24130)
  Update taiki-e/install-action action to v2.68.32 (#24123)
  Update Rust crate serde_with to v3.18.0 (#24126)
  Update Swatinem/rust-cache action to v2.9.1 (#24127)
  Update Rust crate quick-junit to 0.6.0 (#24125)
  Update Rust crate clap to v4.6.0 (#24124)
  Update Rust crate tracing-subscriber to v0.3.23 (#24122)
  ...
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 ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants