Apply signature hooks to decorator applications - #21912
Open
afonsojanu wants to merge 1 commit into
Open
Conversation
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.
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
注册 for free
to join this conversation on GitHub.
Already have an account?
登录 to comment
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.
Fixes #21904
visit_decorator_innercallscheck_calldirectly on the decorator's type, so a plugin'sget_function_signature_hook/get_method_signature_hooknever gets a chance to run for a decorator application. Those two hooks only ever fire from insidetransform_callee_type, and every other call site that wants them calls that first before reachingcheck_call.get_function_hook/get_method_hookstill work fine on a decorator, sincecheck_callinvokes 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_typeon 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_hookfixture, 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.pysuite (8043 passed, 33 skipped, 7 xfailed) plus mypy's own self-check on the changed file, both clean.