Skip to content

Commit a4f1992

Browse files
authored
Improve decorator (#13703)
1 parent 494a5d1 commit a4f1992

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
decorator.ContextManager.__init__
21
decorator.FunctionMaker.args
32
decorator.FunctionMaker.kwonlyargs
43
decorator.FunctionMaker.kwonlydefaults
54
decorator.FunctionMaker.varargs
65
decorator.FunctionMaker.varkw
7-
decorator.decorate
8-
decorator.decorator
9-
decorator.get_init
10-
decorator.EMPTY

stubs/decorator/decorator.pyi

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import inspect
22
from builtins import dict as _dict # alias to avoid conflicts with attribute name
3-
from collections.abc import Callable, Iterator
3+
from collections.abc import Callable, Generator, Iterator
44
from contextlib import _GeneratorContextManager
55
from inspect import Signature, getfullargspec as getfullargspec, iscoroutinefunction as iscoroutinefunction
66
from re import Pattern
7-
from typing import Any, Literal, TypeVar
7+
from typing import Any, Final, Literal, TypeVar
88
from typing_extensions import ParamSpec
99

1010
_C = TypeVar("_C", bound=Callable[..., Any])
1111
_Func = TypeVar("_Func", bound=Callable[..., Any])
1212
_T = TypeVar("_T")
1313
_P = ParamSpec("_P")
1414

15-
def get_init(cls: type) -> None: ...
16-
17-
DEF: Pattern[str]
18-
POS: Literal[inspect._ParameterKind.POSITIONAL_OR_KEYWORD]
15+
DEF: Final[Pattern[str]]
16+
POS: Final[Literal[inspect._ParameterKind.POSITIONAL_OR_KEYWORD]]
17+
EMPTY: Final[type[inspect._empty]]
1918

2019
class FunctionMaker:
2120
args: list[str]
@@ -59,13 +58,14 @@ class FunctionMaker:
5958
) -> Callable[..., Any]: ...
6059

6160
def fix(args: tuple[Any, ...], kwargs: dict[str, Any], sig: Signature) -> tuple[tuple[Any, ...], dict[str, Any]]: ...
62-
def decorate(func: _Func, caller: Callable[..., Any], extras: Any = ...) -> _Func: ...
61+
def decorate(func: _Func, caller: Callable[..., Any], extras: tuple[Any, ...] = ..., kwsyntax: bool = False) -> _Func: ...
6362
def decoratorx(caller: Callable[..., Any]) -> Callable[..., Any]: ...
6463
def decorator(
65-
caller: Callable[..., Any], _func: Callable[..., Any] | None = ...
64+
caller: Callable[..., Any], _func: Callable[..., Any] | None = None, kwsyntax: bool = False
6665
) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ...
6766

6867
class ContextManager(_GeneratorContextManager[_T]):
68+
def __init__(self, g: Callable[..., Generator[_T]], *a: Any, **k: Any) -> None: ...
6969
def __call__(self, func: _C) -> _C: ...
7070

7171
def contextmanager(func: Callable[_P, Iterator[_T]]) -> Callable[_P, ContextManager[_T]]: ...

0 commit comments

Comments
 (0)