Created
July 30, 2024 13:46
-
-
Save CodeByAidan/20ff40a9d6a71f9396ca9d708c923034 to your computer and use it in GitHub Desktop.
functools.wraps return type decorator template
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
from typing import Callable, Generic, ParamSpec, Protocol, TypeVar, overload | |
_PD = ParamSpec('_PD') | |
_PF = ParamSpec('_PF') | |
_RD = TypeVar('_RD') | |
_RF = TypeVar('_RF') | |
# from functools import _Wrapped as _W | |
class _W(Generic[_PF, _RF, _PD, _RD]): | |
... | |
class _DecoOrFab(Protocol[_PD, _RD]): | |
@overload | |
def __call__(self, f: Callable[_PF, _RF]) -> _W[_PF, _RF, ..., _RD]: ... | |
@overload | |
def __call__(self, **kwargs) -> _W[_PD, _RD, ..., ...]: ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment