-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix Incompatible return value type
error message for long tuple with Union
and non-Union
type mismatch
#18881
Merged
hauntsaninja
merged 6 commits into
python:master
from
Luunynliny:fix/incompatible_tuple_error_message
Apr 6, 2025
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a58a971
fix: check for type strict equality to include union and non-union mi…
Luunynliny 220a2f4
test: union and non-union type mismatch case
Luunynliny 11a6c13
refactor: tuple types subtype check
Luunynliny 9109962
test: wider expected return value
Luunynliny 57177bf
test: better case names
Luunynliny e36a0c7
refactor: move test
Luunynliny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Please add a testcase with the opposite direction (annotated with tuple of unions, returns tuple of props)
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.
@sterliakov Just to make sure I understand, you would like me to test this configuration ?
Or something else ?
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.
I'd love to see a test where the expected return type is wider than the actual return type, but the changed method is still triggered. In your example all items are assignable, so that method won't fire. Something like
I adjusted the third union item to not be assignable, so that the comparator should be triggered (please check that it actually is). And why is
x
a property, won't a simpler test without class do (and same question about the test you already added)?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.
And a nit: please move this to
check-tuples.test
as the long tuple is the problem here, not the surrounding class.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.
Thanks for the clarification and the provided example.
It indeed triggers to relevant error. I also a
Union
to modified code works as expected.Beside beging the configuration where I first encountered the error message issue, your suggestion triggers an
Incompatible types in assignment
(which works correctly) instead of aIncompatible return value type
.