forked from zulip/zulip
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
decorator: Fix type of signature-changing decorators.
In a decorator annotated with generic type (ViewFuncT) -> ViewFuncT, the type variable ViewFuncT = TypeVar(…) must be instantiated to the *same* type in both places. This amounts to a claim that the decorator preserves the signature of the view function, which is not the case for decorators that add a user_profile parameter. The corrected annotations enforce no particular relationship between the input and output signatures, which is not the ideal type we might get if mypy supported variadic generics, but is better than enforcing a relationship that is guaranteed to be wrong. This removes a bunch of ‘# type: ignore[call-arg] # mypy doesn't seem to apply the decorator’ annotations. Mypy does apply the decorator, but the decorator’s incorrect annotation as signature-preserving made it appear as if it didn’t. Signed-off-by: Anders Kaseorg <[email protected]>
- Loading branch information
Showing
3 changed files
with
43 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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