Skip to content

Apply signature hooks to decorator applications - #21912

Open
afonsojanu wants to merge 1 commit into
python:masterfrom
afonsojanu:fix/decorator-signature-hook-21904
Open

Apply signature hooks to decorator applications#21912
afonsojanu wants to merge 1 commit into
python:masterfrom
afonsojanu:fix/decorator-signature-hook-21904

Conversation

@afonsojanu

Copy link
Copy Markdown

Fixes #21904

visit_decorator_inner calls check_call directly on the decorator's type, so a plugin's get_function_signature_hook/get_method_signature_hook never gets a chance to run for a decorator application. Those two hooks only ever fire from inside transform_callee_type, and every other call site that wants them calls that first before reaching check_call. get_function_hook/get_method_hook still work fine on a decorator, since check_call invokes those two on its own, which made the gap easy to miss: half the plugin hook family works on a decorator and half silently doesn't.

Calling transform_callee_type on the decorator's type before checking the call closes the gap the same way an ordinary call already gets it.

Added a test reusing the existing function_sig_hook fixture, applied as a decorator instead of a plain call, since nothing in the suite exercised a signature hook on a decorator before this.

Ran the full testcheck.py suite (8043 passed, 33 skipped, 7 xfailed) plus mypy's own self-check on the changed file, both clean.

visit_decorator_inner calls check_call directly on the decorator's
type, so a plugin's get_function_signature_hook or
get_method_signature_hook never gets a chance to run: those two only
ever fire from inside transform_callee_type, and every other call site
that wants them calls that first. get_function_hook and
get_method_hook still work fine here, since check_call invokes those
two on its own, which is what made the gap easy to miss: half the
plugin hook family works on a decorator and half silently doesn't.

Calling transform_callee_type on the decorator's type before checking
the call closes the gap the same way an ordinary call already gets it.

Added a test reusing the existing function_sig_hook fixture, applied
as a decorator instead of a plain call, since nothing in the suite
exercised a signature hook on a decorator before.
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

注册 for free to join this conversation on GitHub. Already have an account? 登录 to comment

标签

None yet

项目

None yet

Development

Successfully merging this pull request may close these issues.

get_function_signature_hook is not invoked on function decorators

1 participant