Skip to content

Add function definition notes for more call argument errors#20794

Draft
KevinRK29 wants to merge 1 commit intopython:masterfrom
KevinRK29:add-more-note-defined-messages
Draft

Add function definition notes for more call argument errors#20794
KevinRK29 wants to merge 1 commit intopython:masterfrom
KevinRK29:add-more-note-defined-messages

Conversation

@KevinRK29
Copy link
Collaborator

This PR helps improve error messages for call argument errors by adding a note that indicates where that called function is defined

  • too few arguments
  • missing named arguments
  • too many arguments
  • too many positional arguments

@KevinRK29 KevinRK29 requested a review from JukkaL February 13, 2026 07:49
@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/server/orchestration/rules.py:408: note: "validate_proposed_state" of "TaskOrchestrationContext" defined here
+ src/prefect/server/orchestration/rules.py:251: note: "validate_proposed_state" of "FlowOrchestrationContext" defined here
+ src/prefect/infrastructure/provisioners/__init__.py:47: note: "provision" of "Provisioner" defined here

pydantic (https://github.com/pydantic/pydantic)
+ ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/annotationlib.pyi:48: note: "ForwardRef" defined here
+ ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:121: note: Called function defined here

starlette (https://github.com/encode/starlette)
+ starlette/concurrency.py:30: note: "run_in_threadpool" defined here

zulip (https://github.com/zulip/zulip)
+ ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "Foo" defined here
+ ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "CustomType" defined here

core (https://github.com/home-assistant/core)
+ .../projects/_core_venv/lib/python3.14/site-packages/aiohttp/web_exceptions.py:90: note: "HTTPRedirection" defined here

steam.py (https://github.com/Gobot1234/steam.py)
+ steam/state.py:1623: note: "react_to_chat_message" of "ConnectionState" defined here
+ steam/state.py:1540: note: "ack_chat_message" of "ConnectionState" defined here
+ ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "object" defined here

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+ ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/_contextvars.pyi:58: note: "run" of "Context" defined here

urllib3 (https://github.com/urllib3/urllib3)
+ src/urllib3/__init__.py:117: note: "request" defined here

porcupine (https://github.com/Akuli/porcupine)
+ .../projects/_porcupine_venv/lib/python3.14/site-packages/tree_sitter-stubs/binding.pyi:67: note: "Parser" defined here
+ ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "Query" defined here

pandas (https://github.com/pandas-dev/pandas)
+ ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:118: note: "__new__" of "object" defined here

ibis (https://github.com/ibis-project/ibis)
+ ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "MapSet" defined here
+ ibis/common/grounds.py:195: note: "Value" defined here
+ ibis/expr/types/temporal_windows.py:32: note: "WindowedTable" defined here
+ ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/functools.pyi:103: note: "__call__" of "_Wrapped" defined here
+ ibis/expr/operations/generic.py:169: note: "ScalarParameter" defined here
+ ibis/common/patterns.py:1512: note: "PatternList" defined here
+ ibis/common/grounds.py:128: note: "StringOp" defined here
+ ibis/common/grounds.py:128: note: "AnnSing" defined here
+ ibis/common/grounds.py:128: note: "SingAnn" defined here
+ ibis/backends/singlestoredb/converter.py:253: note: "_get_type_name" defined here
+ ibis/backends/singlestoredb/converter.py:305: note: "convert_SingleStoreDB_type" defined here

werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/datastructures/headers.py:225: note: "extend" of "Headers" defined here

cryptography (https://github.com/pyca/cryptography)
+ src/cryptography/hazmat/bindings/_rust/openssl/kdf.pyi:168: note: "KBKDFHMAC" defined here
+ src/cryptography/hazmat/bindings/_rust/openssl/kdf.pyi:188: note: "KBKDFCMAC" defined here

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ pandas-stubs/core/strings/accessor.pyi:186: note: "wrap" of "StringMethods" defined here

apprise (https://github.com/caronc/apprise)
+ ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "IRCMessage" defined here

materialize (https://github.com/MaterializeInc/materialize)
+ ...venv/lib/python3.14/site-packages/mypy/typeshed/stdlib/builtins.pyi:117: note: "__init__" of "object" defined here

xarray (https://github.com/pydata/xarray)
+ xarray/tests/test_deprecation_helpers.py: note: In function "test_deprecate_positional_args_warns_for_class":
+ xarray/tests/test_deprecation_helpers.py:72: note: "method" of "A1" defined here
+ xarray/tests/test_deprecation_helpers.py:95: note: "method" of "A2" defined here
+ xarray/tests/test_deprecation_helpers.py:108: note: "method" of "A3" defined here
+ xarray/tests/test_deprecation_helpers.py:121: note: "method" of "A4" defined here
+ xarray/core/dataarray.py: note: In function "test_multiple_groupers_string":
+ xarray/core/dataarray.py:6877: note: "groupby" of "DataArray" defined here

@ilevkivskyi
Copy link
Member

I don't know how much context @JukkaL gave you, but let's wait with this until I am done with my part of the work (switching to more standard message formatting for this note) first.

Also maybe we should not add it to so many places at once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants