-
-
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
assert_type() not matching function type #15153
Comments
The two types are not equivalent. The function def myfunc(arg: int, /) -> None:
pass |
What should we show in the error message, given there's no special form for this? |
@erictraut is correct, but the error message mypy gives here isn't particularly helpful. Let's keep this issue open to track improving the error message. |
FWIW, here's the error message that pyright emits:
In pyright's error messages, I output a callable syntax that is based on the proposed (but unfortunately rejected) PEP 677. Not sure if this is something mypy maintainers would consider adopting. |
I see, thank you very much for the clarification. The error message had me assuming it was a bug. |
It's definitely an error message bug, since we mention the same string on both sides. |
This has been fixed on the master branch. The error message now shows:
You can see this in the playground: https://mypy-play.net/?mypy=master&python=3.11&gist=50dde8e891d971d823c4c6af2e639834 |
Apparently fixed by #15184. @AlexWaygood, can we close? |
Doesn't look like a regression test was added for this specific case — fancy making a PR? :) |
Bug Report
'assert_type()' refuses to match a function to its own type.
To Reproduce
Expected Behavior
No error.
Actual Behavior
The error disappears if the function takes no arguments.
Your Environment
mypy.ini
(and other config files): defaultThe text was updated successfully, but these errors were encountered: