Skip to content

Call function signature hooks when checking decorators - #22130

Open
Cherith1222 wants to merge 2 commits into
python:masterfrom
Cherith1222:fix/21904-signature-hook-decorators
Open

Cherith1222 wants to merge 2 commits into
python:masterfrom
Cherith1222:fix/21904-signature-hook-decorators

Conversation

@Cherith1222

Copy link
Copy Markdown

Summary

Decorator calls never reached get_function_signature_hook, so a plugin could not adjust that signature the way it can for a normal call. Checking a decorator now invokes the hook.

Fixes #21904.

Test Plan

On Windows, Python from this checkout's .venv, PYTEST_DISABLE_PLUGIN_AUTOLOAD=1, Resource Sentinel MEDIUM (1 CPU, 2.5–3 GiB):

  • Before the change, the new test failed. After it, the new test and two existing plugin tests each passed.
  • python -m pytest -o addopts= -p no:cacheprovider mypy/test/testcheck.py::TypeCheckSuite::check-custom-plugin.test -q → 65 passed.
  • The same prefix with mypy/test/testcheck.py -k decorator → 112 passed, 8205 deselected.
  • check-functions.test, check-functools.test, check-singledispatch.test, check-plugin-attrs.test, check-dataclasses.test, and check-dataclass-transform.test → 658 passed, 2 xfailed (the two existing -xfail cases in check-singledispatch.test).

Not run: the full mypy suite, mypy_primer, the daemon / fine-grained mode, and mypyc.

AI assistance

Drafted with Cursor. The account owner authorized opening this pull request. A human has not reviewed the diff. There is no Co-authored-by, Reviewed-by, or Signed-off-by trailer.

Cherith1222 and others added 2 commits October 6, 2026 11:34
Decorator calls never reached get_function_signature_hook, so a plugin could not adjust that signature the way a normal call can. AI-assisted (Cursor); not yet reviewed.
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

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

scipy-stubs (https://github.com/scipy/scipy-stubs)
- tests/misc/test_submodules_empty.pyi:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

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.

get_function_signature_hook is not invoked on function decorators

1 participant