summaryrefslogtreecommitdiffstats
path: root/tests/typing_test_data.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 17:25:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 17:25:40 +0000
commitcf7da1843c45a4c2df7a749f7886a2d2ba0ee92a (patch)
tree18dcde1a8d1f5570a77cd0c361de3b490d02c789 /tests/typing_test_data.py
parentInitial commit. (diff)
downloadsphinx-cf7da1843c45a4c2df7a749f7886a2d2ba0ee92a.tar.xz
sphinx-cf7da1843c45a4c2df7a749f7886a2d2ba0ee92a.zip
Adding upstream version 7.2.6.upstream/7.2.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/typing_test_data.py')
-rw-r--r--tests/typing_test_data.py129
1 files changed, 129 insertions, 0 deletions
diff --git a/tests/typing_test_data.py b/tests/typing_test_data.py
new file mode 100644
index 0000000..8a7ebc4
--- /dev/null
+++ b/tests/typing_test_data.py
@@ -0,0 +1,129 @@
+from inspect import Signature
+from numbers import Integral
+from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union
+
+
+def f0(x: int, y: Integral) -> None:
+ pass
+
+
+def f1(x: list[int]) -> List[int]:
+ pass
+
+
+T = TypeVar('T')
+T_co = TypeVar('T_co', covariant=True)
+T_contra = TypeVar('T_contra', contravariant=True)
+
+
+def f2(x: List[T], y: List[T_co], z: T) -> List[T_contra]:
+ pass
+
+
+def f3(x: Union[str, Integral]) -> None:
+ pass
+
+
+MyStr = str
+
+
+def f4(x: 'MyStr', y: MyStr) -> None:
+ pass
+
+
+def f5(x: int, *, y: str, z: str) -> None:
+ pass
+
+
+def f6(x: int, *args, y: str, z: str) -> None:
+ pass
+
+
+def f7(x: int = None, y: dict = {}) -> None: # NoQA: B006
+ pass
+
+
+def f8(x: Callable[[int, str], int]) -> None:
+ # See https://github.com/ambv/typehinting/issues/149 for Callable[..., int]
+ pass
+
+
+def f9(x: Callable) -> None:
+ pass
+
+
+def f10(x: Tuple[int, str], y: Tuple[int, ...]) -> None:
+ pass
+
+
+class CustomAnnotation:
+ def __repr__(self):
+ return 'CustomAnnotation'
+
+
+def f11(x: CustomAnnotation(), y: 123) -> None:
+ pass
+
+
+def f12() -> Tuple[int, str, int]:
+ pass
+
+
+def f13() -> Optional[str]:
+ pass
+
+
+def f14() -> Any:
+ pass
+
+
+def f15(x: "Unknown", y: "int") -> Any: # noqa: F821 # type: ignore[attr-defined]
+ pass
+
+
+def f16(arg1, arg2, *, arg3=None, arg4=None):
+ pass
+
+
+def f17(*, arg3, arg4):
+ pass
+
+
+def f18(self, arg1: Union[int, Tuple] = 10) -> List[Dict]:
+ pass
+
+
+def f19(*args: int, **kwargs: str):
+ pass
+
+
+def f20() -> Optional[Union[int, str]]:
+ pass
+
+
+def f21(arg1='whatever', arg2=Signature.empty):
+ pass
+
+
+def f22(*, a, b):
+ pass
+
+
+def f23(a, b, /, c, d):
+ pass
+
+
+def f24(a, /, *, b):
+ pass
+
+
+def f25(a, b, /):
+ pass
+
+
+class Node:
+ def __init__(self, parent: Optional['Node']) -> None:
+ pass
+
+ def children(self) -> List['Node']:
+ pass