-
-
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
feat: better message if method incompatible with base class #10572
feat: better message if method incompatible with base class #10572
Conversation
A couple interesting observations with the existing behavior of CallableType and mypy/messages.py's pretty_callable (below) Lines 1932 to 1949 in 10ea6ad
First, when printing
Second, I had to split Not sure if this is expected behavior or a bug. Let me know what you think! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@atakiar Could you look into some of the mypy_primer errors? I'm a little nervous about all of the missing errors, though it wouldn't shock me if some of them had been wrong? |
@msullivan I think new commits made their way to master between my last merge and when the mypy_primer workflow ran (triggered manually for first-time mypy contributors). Trying this again, hopefully it’ll come out looking better this time! |
This comment has been minimized.
This comment has been minimized.
@msullivan let me know what you think! By the way, the missing mypy_primer errors are the result of #10579. The new multiline note along with the restriction on number of errors shown, results in the last few errors now being hidden |
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: aioredis (https://github.com/aio-libs/aioredis.git)
+ aioredis/client.py:4286: note: Superclass:
+ aioredis/client.py:4286: note: def (self: Redis) -> Any
+ aioredis/client.py:4286: note: Subclass:
+ aioredis/client.py:4286: note: def __aenter__(self) -> Coroutine[Any, Any, Pipeline]
|
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, this is absolutely fantastic. Thanks so much for this!
Description
Closes #3379. See PR #3410 for some context
Currently if a method is incompatible with a base class, mypy just states the name of the base class but doesn't actually give more details about the expected signature
This PR makes it so that incompatible methods will print out easily-readable signatures, like follows:
Test Plan
Updated the relevant test cases. No new test cases were added