mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
Update the signature of decorator.decorator (#3336)
Nothing prevents a decorator defined using `@decorator` from
changing the signature of the decorated function. For example,
this example changes the return type to `str`:
```
from decorator import decorator
@decorator
def stringify(f, *args, **kwargs) -> str:
return str(f(*args, **kwargs))
```
The old signature caused false positives in internal Dropbox code.
I couldn't come up with a signature that would produce better types
with mypy while not generating false positives.
This commit is contained in:
2
third_party/2and3/decorator.pyi
vendored
2
third_party/2and3/decorator.pyi
vendored
@@ -75,7 +75,7 @@ class FunctionMaker(object):
|
||||
) -> Callable[..., Any]: ...
|
||||
|
||||
def decorate(func: _Func, caller: Callable[..., Any], extras: Any = ...) -> _Func: ...
|
||||
def decorator(caller: Callable[..., Any], _func: Optional[Callable[..., Any]] = ...) -> Callable[[_C], _C]: ...
|
||||
def decorator(caller: Callable[..., Any], _func: Optional[Callable[..., Any]] = ...) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ...
|
||||
|
||||
class ContextManager(_GeneratorContextManager[_T]):
|
||||
def __call__(self, func: _C) -> _C: ...
|
||||
|
||||
Reference in New Issue
Block a user