-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Understandable error message for incompatible AnyStr arguments #3433
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
Closed
Closed
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
2bc24f3
New message for anystr errors
quartox 36e66de
Fix logic path of anystr args
quartox 7816c4f
Add tests
quartox 6c3e822
Add docstring
quartox 4c408e7
Fix tests
quartox 9ee35b7
Get all AnyStr failures
quartox 066fde6
Clean up error message
quartox c108a58
Fix tests
quartox 4a133bd
Check for any constrained type
quartox 982f4b7
Revert "Check for any constrained type"
quartox 436925e
Revert "Revert "Check for any constrained type""
quartox bcf86dd
Revert "Merge with mypy master"
quartox 13dcb81
Fix typeshed
quartox 079bff6
Fix spacing
quartox 9aaec96
Merge branch 'master' of https://github.com/python/mypy into anystr
quartox 5c2b024
Test checkout upstream/master
quartox 2bf23ca
Fix inappropriate updates to files
quartox d280d91
Finish cleanup of inappropriate additions
quartox 36e3de1
Merge branch 'master' of https://github.com/python/mypy into anystr
quartox 533260d
Improve checking
quartox 93a7d58
Sparser testing
quartox 7465cf8
Use MessageBuilder to get type strings
quartox e88b7b5
Add indeces to AnyStr error message
quartox 2495e33
Merge branch 'master' of https://github.com/python/mypy into anystr
quartox 7c3dd7b
Small change to error message
quartox 5d77828
Fix some test messages
quartox 24bdbe0
Fix more error messages
quartox 30f98ab
Remove brittle indeces of inferred object
quartox 092f7a7
Merge branch 'master' of https://github.com/python/mypy into anystr
quartox 36fdd0f
Remove mutliple indeces from tests
quartox b746fe8
Fix test typo
quartox 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
This error message is better than existing but still quite confusing. Ca you make it less terse?
Maybe something in the spirit of "Arguments 1, 2, and 4 to 'my_function' should be either all 'str' or all 'bytes'. Got (str, str, bytes)."
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 think I can probably find the argument indices easily enough, but the types of the other arguments isn't available when constructing the message because the message builder only gets called when the second argument is analyzed (from what I can tell, please let me know if there is something I have overlooked). I can get
mypy.nodes.StrExpr
andmypy.nodes.BytesExpr
fromcontext
, but I do not know how to safely get these values asMessageBuilder.format
for both of these returnsobject
.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.
OK, then again we could postpone this to the next PR (probably the idea is to use
types
argument forapply_generic_arguments
andmap_actuals_to_formals
fromcheckexpr.py
).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.
Still I think that error message like "Arguments 1, 2, and 4 to 'my_function' should be either all 'str' or all 'bytes'" will look better than the current one, so it is better to change it in this PR.