Skip to content

Commit 5b44391

Browse files
author
Raf Blecher
committed
Add type stub for decorator lib
1 parent 395ce49 commit 5b44391

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

third_party/2and3/decorator.pyi

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import sys
2+
from typing import Any, Callable, Dict, List, NamedTuple, Optional, Pattern, Text, Tuple, TypeVar
3+
4+
_C = TypeVar("_C", bound=Callable[..., Any])
5+
_Func = TypeVar("_Func", bound=Callable[..., Any])
6+
7+
def get_init(cls): ...
8+
9+
# Duplicated from `stdlib/3/inspect.pyi`
10+
FullArgSpec = NamedTuple('FullArgSpec', [('args', List[str]),
11+
('varargs', Optional[str]),
12+
('varkw', Optional[str]),
13+
('defaults', tuple),
14+
('kwonlyargs', List[str]),
15+
('kwonlydefaults', Dict[str, Any]),
16+
('annotations', Dict[str, Any]),
17+
])
18+
19+
if sys.version_info >= (3,):
20+
iscoroutinefunction: Callable[[Callable[..., Any]], bool] = ... # really inspect.iscoroutinefunction
21+
getfullargspec: Callable[[Any], FullArgSpec] = ... # really inspect.getfullargspec
22+
else:
23+
def iscoroutinefunction(f: Callable[..., Any]) -> bool: ...
24+
def getfullargspec(func: Any) -> FullArgSpec: ...
25+
26+
if sys.version_info >= (3, 2):
27+
from contextlib import _GeneratorContextManager
28+
else:
29+
from contextlib import GeneratorContextManager as _GeneratorContextManager
30+
31+
DEF: Pattern[Text]
32+
33+
class FunctionMaker(object):
34+
args: List[Text]
35+
varargs: Optional[Text]
36+
varkw: Optional[Text]
37+
defaults: Tuple[Any]
38+
kwonlyargs: List[Text]
39+
kwonlydefaults: Optional[Text]
40+
shortsignature: Optional[Text]
41+
name: Text
42+
doc: Optional[Text]
43+
module: Optional[Text]
44+
annotations: Dict[Text, Any]
45+
signature: Text
46+
dict: Dict[Text, Any]
47+
def __init__(
48+
self,
49+
func: Optional[Callable[..., Any]] = ...,
50+
name: Optional[Text] = ...,
51+
signature: Optional[Text] = ...,
52+
defaults: Optional[Tuple[Any]] = ...,
53+
doc: Optional[Text] = ...,
54+
module: Optional[Text] = ...,
55+
funcdict: Optional[Dict[Text, Any]] = ...
56+
) -> None: ...
57+
def update(self, func: Any, **kw: Dict[Text, Any]) -> None: ...
58+
def make(
59+
self,
60+
src_templ: Text,
61+
evaldict: Optional[Dict[Text, Any]] = ...,
62+
addsource: bool = ...,
63+
**attrs: Any
64+
) -> Callable[..., Any]: ...
65+
@classmethod
66+
def create(
67+
cls,
68+
obj: Any,
69+
body: Text,
70+
evaldict: Dict[Text, Any],
71+
defaults: Optional[Tuple[Any]] = ...,
72+
doc: Optional[Text] = ...,
73+
module: Optional[Text] = ...,
74+
addsource: bool = ...,
75+
**attrs: Any
76+
) -> Callable[..., Any]: ...
77+
78+
def decorate(func: _Func, caller: Callable[..., Any], extras: Any = ...) -> _Func: ...
79+
def decorator(caller: Callable[..., Any], _func: Optional[Callable[..., Any]] = ...) -> Callable[[_C], _C]: ...
80+
81+
class ContextManager(_GeneratorContextManager):
82+
def __call__(self, func: _C) -> _C: ...
83+
84+
def contextmanager(func: _C) -> _C: ...
85+
def dispatch_on(*dispatch_args: Any) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ...

0 commit comments

Comments
 (0)