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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[red-knot] Implement disjointness for Instance types where the underlying class is
@final
#15539[red-knot] Implement disjointness for Instance types where the underlying class is
@final
#15539Changes from 4 commits
1c77b78
099e3f7
7765965
1d78b74
dac2982
d6c4521
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I like that we can delegate to instance-vs-instance, rather than checking finality here also.
It seems right that
T
actually disappears from this check, apart from its metaclass. There's no difference betweentype[object]
andtype[OtherClass]
as regards disjointness from an instance type, as long as the metaclass ofOtherClass
is justtype
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carljm I realised almost as soon as our pairing session here that we were missing some subtle edge cases where a
type[T]
type could still be disjoint from an instance type even if the instance type was a subtype oftype
. So this logic is a little fiddlier than what we initially implemented. See the mdtest I've added for examples!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a property test reveal this, or you just realized it looking at the code/tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just me reading the diff on github prior to filing the PR!