GeezerVison is showing github.com — Use standard formatting for note on unexpected keyword by ilevkivskyi · Pull Request #20808 · python/mypy
Conversation
Closes #4773
Closes #10480
Closes #20640
Currently this is the only message that uses this non-standard formatting, while:
- Some users find it confusing
- We need ~400 lines of code to support this special case
- It still has bugs that will require even more special-casing in various places to fix them.
So here I implement a minimal change I propose in #4773, namely use this (standard) format:
main.py:5: error: Unexpected keyword argument "location" for "method" of "Class"
main.py:5: note: "method" defined in "pkg.mod"
if the function is defined in a different module.
If we want to, we can add extra info (like available argument names with same type), as well as start using this note in more places in separate PRs.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
|
Hm, looking at the mypy_primer output I think we should skip this note for builtins and typing, it doesn't look very helpful.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Diff from mypy_primer, showing the effect of this PR on open source code:
prefect (https://github.com/PrefectHQ/prefect)
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here
+ src/prefect/states.py:581: note: "resolve_result_storage" defined in "prefect.results"
- src/prefect/results.py:166: note: "resolve_result_storage" defined here
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here
- src/prefect/blocks/core.py:1545: note: "register_type_and_schema" of "Block" defined here
+ src/prefect/results.py:183: note: "load" defined in "prefect.blocks.core"
- src/prefect/blocks/core.py:1137: note: "load" of "Block" defined here
- src/prefect/results.py:104: note: "get_default_result_storage" defined here
- src/prefect/results.py:166: note: "resolve_result_storage" defined here
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here
+ src/prefect/flows.py:601: note: "load_from_ref" defined in "prefect.blocks.core"
- src/prefect/blocks/core.py:1302: note: "load_from_ref" of "Block" defined here
- src/prefect/deployments/runner.py:1250: note: "from_storage" of "RunnerDeployment" defined here
+ src/prefect/flows.py:946: note: "from_storage" defined in "prefect.deployments.runner"
- src/prefect/results.py:166: note: "resolve_result_storage" defined here
+ src/prefect/flows.py:2548: note: "resolve_result_storage" defined in "prefect.results"
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here
- src/prefect/results.py:397: note: "update_for_flow" of "ResultStore" defined here
+ src/prefect/flow_engine.py:493: note: "update_for_flow" defined in "prefect.results"
+ src/prefect/flow_engine.py:813: note: "update_for_flow" defined in "prefect.results"
+ src/prefect/flow_engine.py:1097: note: "update_for_flow" defined in "prefect.results"
+ src/prefect/flow_engine.py:1414: note: "update_for_flow" defined in "prefect.results"
+ src/prefect/task_engine.py:777: note: "update_for_task" defined in "prefect.results"
- src/prefect/results.py:473: note: "update_for_task" of "ResultStore" defined here
- src/prefect/artifacts.py:84: note: "create" of "Artifact" defined here
- src/prefect/artifacts.py:151: note: "get" of "Artifact" defined here
- src/prefect/artifacts.py:248: note: "format" of "Artifact" defined here
- src/prefect/artifacts.py:334: note: "format" of "ProgressArtifact" defined here
pydantic (https://github.com/pydantic/pydantic)
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/typing.pyi:1065: note: "evaluate_forward_ref" defined here
- .../projects/_pydantic_venv/lib/python3.14/site-packages/pydantic_core/_pydantic_core.pyi:76: note: "SchemaValidator" defined here
+ pydantic/plugin/_schema_validator.py:53: note: "SchemaValidator" defined in "pydantic_core._pydantic_core"
+ pydantic/plugin/_schema_validator.py:72: note: "SchemaValidator" defined in "pydantic_core._pydantic_core"
- .../projects/_pydantic_venv/lib/python3.14/site-packages/pydantic_core/_pydantic_core.pyi:300: note: "SchemaSerializer" defined here
+ pydantic/_internal/_model_construction.py:694: note: "SchemaSerializer" defined in "pydantic_core._pydantic_core"
starlette (https://github.com/encode/starlette)
- starlette/websockets.py:21: note: "WebSocketDenialResponse" defined here
+ starlette/testclient.py:155: note: "WebSocketDenialResponse" defined in "starlette.websockets"
zulip (https://github.com/zulip/zulip)
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "SubTest" defined here
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "SubmessageFixture" defined here
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "FileFixture" defined here
strawberry (https://github.com/strawberry-graphql/strawberry)
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here
core (https://github.com/home-assistant/core)
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here
aiortc (https://github.com/aiortc/aiortc)
- .../projects/_aiortc_venv/lib/python3.14/site-packages/OpenSSL-stubs/SSL.pyi:144: note: "get_peer_certificate" of "Connection" defined here
+ src/aiortc/rtcdtlstransport.py:437: note: "get_peer_certificate" defined in "OpenSSL.SSL"
discord.py (https://github.com/Rapptz/discord.py)
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/typing.pyi:1046: note: "update" of "TypedDict" defined here
ibis (https://github.com/ibis-project/ibis)
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "Any" defined here
- ibis/expr/operations/generic.py:145: note: "Literal" defined here
+ ibis/expr/operations/tests/test_generic.py:112: note: "Literal" defined in "ibis.expr.operations.generic"
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "__init__" of "object" defined here
apprise (https://github.com/caronc/apprise)
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "IRCMessage" defined here
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "IRCAction" defined here
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "IRCContext" defined here
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "IRCContext" defined here
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "XMPPConfig" defined here
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "IRCContext" defined here
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "IRCAction" defined here
- ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "XMPPConfig" defined here
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
hauntsaninja
left a comment
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
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! Great that this is so much cleaner too
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
JukkaL
Awaiting requested review from JukkaL
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.