-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommon_types.py
More file actions
86 lines (59 loc) · 3.48 KB
/
Copy pathcommon_types.py
File metadata and controls
86 lines (59 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import sys
from typing import (
Any,
Callable,
Dict,
Iterator,
List,
Optional,
Protocol,
Tuple,
TypeVar,
Union,
overload,
)
if sys.version_info >= (3, 10):
from typing import ParamSpec # pragma: no cover
else:
from typing_extensions import ParamSpec # pragma: no cover
SlotParameters = ParamSpec('SlotParameters')
PluginResult = TypeVar('PluginResult')
SlotCallResult = TypeVar('SlotCallResult')
SlotCallResultCovariant = TypeVar('SlotCallResultCovariant', covariant=True) # noqa: PLC0105
PluginResultCovariant = TypeVar('PluginResultCovariant', covariant=True) # noqa: PLC0105
DefaultType = TypeVar('DefaultType')
SlotResult = Optional[Union[List[PluginResult], Dict[str, PluginResult]]]
SlotSignature = Union[str, List[str]]
SlotFunction = Callable[SlotParameters, SlotCallResult]
PluginFunction = Callable[SlotParameters, PluginResult]
class PluginProtocol(Protocol[SlotParameters, PluginResultCovariant]): # pragma: no cover
name: str
requested_name: str
def __call__(self, *args: SlotParameters.args, **kwargs: SlotParameters.kwargs) -> PluginResultCovariant: ...
class BaseSlotViewProtocol(Protocol[SlotParameters, SlotCallResultCovariant, PluginResultCovariant]): # pragma: no cover
def __call__(self, *args: SlotParameters.args, **kwargs: SlotParameters.kwargs) -> SlotCallResultCovariant: ...
def __iter__(self) -> Iterator[PluginProtocol[SlotParameters, PluginResultCovariant]]: ...
def __bool__(self) -> bool: ...
def __len__(self) -> int: ...
class SlotSelectionProtocol(BaseSlotViewProtocol[SlotParameters, SlotCallResultCovariant, PluginResultCovariant], Protocol[SlotParameters, SlotCallResultCovariant, PluginResultCovariant]):
pass
class SlotProtocol(BaseSlotViewProtocol[SlotParameters, SlotCallResultCovariant, PluginResult], Protocol[SlotParameters, SlotCallResultCovariant, PluginResult]): # pragma: no cover
@overload
def plugin(self, plugin_function_or_name: Optional[str] = None, unique: bool = False, engine: Optional[Union[List[str], str]] = None, run_once: bool = False) -> Callable[[Callable[SlotParameters, PluginResult]], Callable[SlotParameters, PluginResult]]: ...
@overload
def plugin(self, plugin_function_or_name: Callable[SlotParameters, PluginResult], unique: bool = False, engine: Optional[Union[List[str], str]] = None, run_once: bool = False) -> Callable[SlotParameters, PluginResult]: ...
def keys(self) -> Tuple[str, ...]: ...
def __getitem__(self, key: str) -> SlotSelectionProtocol[SlotParameters, SlotCallResultCovariant, PluginResult]: ...
def __delitem__(self, key: str) -> None: ...
@overload
def pop(self, key: str) -> SlotSelectionProtocol[SlotParameters, SlotCallResultCovariant, PluginResult]: ...
@overload
def pop(self, key: str, default: DefaultType) -> Union[SlotSelectionProtocol[SlotParameters, SlotCallResultCovariant, PluginResult], DefaultType]: ...
def __contains__(self, item: object) -> bool: ...
class SlotDecoratorProtocol(Protocol): # pragma: no cover
@overload
def __call__(self, function: Callable[SlotParameters, List[PluginResult]], /) -> SlotProtocol[SlotParameters, List[PluginResult], PluginResult]: ...
@overload
def __call__(self, function: Callable[SlotParameters, Dict[str, PluginResult]], /) -> SlotProtocol[SlotParameters, Dict[str, PluginResult], PluginResult]: ...
@overload
def __call__(self, function: Callable[SlotParameters, None], /) -> SlotProtocol[SlotParameters, None, Any]: ...