Skip to content

[ty] Explicitly test assignability/subtyping between unions of nominal types and protocols with method members#20557

Merged
AlexWaygood merged 1 commit intomainfrom
alex/proto-union-tests
Sep 25, 2025
Merged

[ty] Explicitly test assignability/subtyping between unions of nominal types and protocols with method members#20557
AlexWaygood merged 1 commit intomainfrom
alex/proto-union-tests

Conversation

@AlexWaygood
Copy link
Copy Markdown
Member

(Stacked on top of #20555; review that PR first!)

Summary

@sharkdp very reasonably asked in #20165 (comment) whether the invoke_descriptor_protocol call here would produce the right result when testing assignability between a union of nominal types and a protocol with a method member:

let Place::Type(attribute_type, Boundness::Bound) = other
.invoke_descriptor_protocol(
db,
self.name,
Place::Unbound.into(),
InstanceFallbackShadowsNonDataDescriptor::No,
MemberLookupPolicy::default(),
)
.place
else {
return ConstraintSet::from(false);
};

This wasn't something we had explicit tests for, so this PR adds some tests for it!

@AlexWaygood AlexWaygood added testing Related to testing Ruff itself ty Multi-file analysis & type inference labels Sep 24, 2025
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!

Base automatically changed from alex/proto-classmethod-staticmethod-tests to main September 25, 2025 09:14
@AlexWaygood AlexWaygood force-pushed the alex/proto-union-tests branch from e02e3dc to 105fe50 Compare September 25, 2025 09:17
@AlexWaygood AlexWaygood enabled auto-merge (squash) September 25, 2025 09:17
@AlexWaygood AlexWaygood merged commit 21be94a into main Sep 25, 2025
35 checks passed
@AlexWaygood AlexWaygood deleted the alex/proto-union-tests branch September 25, 2025 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Related to testing Ruff itself ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants