Debian Codegraph @

tests/test_util/typing_test_data.py

raw
1 from inspect import Signature
2 from numbers import Integral
3 from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, TypeVar, Union
4
5
6 def f0(x: int, y: Integral) -> None:
7 pass
8
9
10 def f1(x: list[int]) -> List[int]:
11 pass
12
13
14 T = TypeVar('T')
15 T_co = TypeVar('T_co', covariant=True)
16 T_contra = TypeVar('T_contra', contravariant=True)
17
18
19 def f2(x: List[T], y: List[T_co], z: T) -> List[T_contra]: # pyright: ignore[reportInvalidTypeVarUse]
20 pass
21
22
23 def f3(x: Union[str, Integral]) -> None:
24 pass
25
26
27 MyStr = str
28
29
30 def f4(x: 'MyStr', y: MyStr) -> None:
31 pass
32
33
34 def f5(x: int, *, y: str, z: str) -> None:
35 pass
36
37
38 def f6(x: int, *args, y: str, z: str) -> None:
39 pass
40
41
42 def f7(x: int = None, y: dict = {}) -> None: # NoQA: B006,RUF013 # ty: ignore[invalid-parameter-default]
43 pass
44
45
46 def f8(x: Callable[[int, str], int]) -> None:
47 # See https://github.com/ambv/typehinting/issues/149 for Callable[..., int]
48 pass
49
50
51 def f9(x: Callable) -> None:
52 pass
53
54
55 def f10(x: Tuple[int, str], y: Tuple[int, ...]) -> None:
56 pass
57
58
59 class CustomAnnotation:
60 def __repr__(self):
61 return 'CustomAnnotation'
62
63
64 def f11(x: CustomAnnotation(), y: 123) -> None:
65 pass
66
67
68 def f12() -> Tuple[int, str, int]:
69 pass
70
71
72 def f13() -> Optional[str]:
73 pass
74
75
76 def f14() -> Any:
77 pass
78
79
80 def f15(x: 'Unknown', y: 'int') -> Any: # NoQA: F821 # type: ignore[attr-defined]
81 pass
82
83
84 def f16(arg1, arg2, *, arg3=None, arg4=None):
85 pass
86
87
88 def f17(*, arg3, arg4):
89 pass
90
91
92 def f18(self, arg1: Union[int, Tuple] = 10) -> List[Dict]:
93 pass
94
95
96 def f19(*args: int, **kwargs: str):
97 pass
98
99
100 def f20() -> Optional[Union[int, str]]:
101 pass
102
103
104 def f21(arg1='whatever', arg2=Signature.empty):
105 pass
106
107
108 def f22(*, a, b):
109 pass
110
111
112 def f23(a, b, /, c, d):
113 pass
114
115
116 def f24(a, /, *, b):
117 pass
118
119
120 def f25(a, b, /):
121 pass
122
123
124 def f26(x: Literal[1, 2, 3] = 1, y: Union[Literal['a'], Literal['b']] = 'a') -> None:
125 pass
126
127
128 class Node:
129 def __init__(self, parent: Optional['Node']) -> None:
130 pass
131
132 def children(self) -> List['Node']:
133 pass