fix: Preserve type signature of annotated async functions - #203
Closed
edgarrmondragon wants to merge 2 commits into
Closed
fix: Preserve type signature of annotated async functions#203edgarrmondragon wants to merge 2 commits into
edgarrmondragon wants to merge 2 commits into
Conversation
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
edgarrmondragon
force-pushed
the
fix/identity-transform-async-decorated
branch
from
August 28, 2026 19:38
a634ce3 to
1beb709
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in 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.
Version 2.4.0 (14bb92f) typed
on_exception/on_predicateasCallable[[Callable[P, T]], Callable[P, T]], usingParamSpec/TypeVarto reconstruct the decorated callable's type.For an
async deffunction, mypy sees its real type asCallable[P, Coroutine[Any, Any, T]]. Reconstructing that type through the decorator's signature made mypy re-elaborate theCoroutine[Any, Any, T]generic, anddisallow_any_decoratedflagged its twoAnyparameters.This is a regression from
2.2.1, which had typed the decorator as a plain identity transform (Callable[[_CallableT], _CallableT],_CallableTbound toCallable[..., Any]).Closes #200