-
Notifications
You must be signed in to change notification settings - Fork 9
/
typed.py
51 lines (39 loc) · 1.04 KB
/
typed.py
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
"""
# PEP 484 - type annotations examples
## Links
[PEP 484 - Type Hints](https://www.python.org/dev/peps/pep-0484/)
"""
from typing import Any, Dict, List, Optional, Tuple, Type, Union
class MyValue:
pass
class Typed:
def __init__(
self,
_value: Union[List[str], str, MyValue] = MyValue(
{
"key1": "value1",
"key2": "value2",
"key3": "value3",
"key4": "value4",
"key5": "value5",
"key6": "value6",
}
),
*,
_name: str = "default",
) -> Dict[str, MyValue]:
pass
@classmethod
def classmethod(cls, _my_value: MyValue, *_args: str, **_kwargs: Any) -> None:
pass
async def async_method(self, _value: str) -> str:
return await self.classmethod(_value)
def my_deco(key):
return key
@my_deco(key="value")
def func(
_list: Tuple[List[str], ...],
_my_value_cls: Type[MyValue] = MyValue,
**_kwargs: None,
) -> Optional[MyValue]:
pass