|
1 | 1 | import datetime
|
2 |
| - |
| 2 | +from collections.abc import Callable, Container, Iterable |
| 3 | +from contextlib import AbstractContextManager as ContextManager |
| 4 | +from re import Pattern |
3 | 5 | from types import TracebackType
|
4 |
| -from typing import ( |
5 |
| - Any, |
6 |
| - Callable, |
7 |
| - Container, |
8 |
| - ContextManager, |
9 |
| - Generic, |
10 |
| - Iterable, |
11 |
| - NoReturn, |
12 |
| - Optional, |
13 |
| - Pattern, |
14 |
| - Text, |
15 |
| - Tuple, |
16 |
| - Type, |
17 |
| - TypeVar, |
18 |
| - Union, |
19 |
| -) |
| 6 | +from typing import Any, Generic, NoReturn, TypeVar |
20 | 7 |
|
21 | 8 | _E = TypeVar("_E", bound=BaseException)
|
22 | 9 | _S = TypeVar("_S")
|
23 | 10 |
|
24 | 11 | class AssertRaisesContext(Generic[_E]):
|
25 |
| - exception: Type[_E] |
26 |
| - msg_fmt: Text |
27 |
| - def __init__(self, exception: Type[_E], msg_fmt: Text = ...) -> None: ... |
| 12 | + exception: type[_E] |
| 13 | + msg_fmt: str |
| 14 | + def __init__(self, exception: type[_E], msg_fmt: str = ...) -> None: ... |
28 | 15 | def __enter__(self: _S) -> _S: ...
|
29 | 16 | def __exit__(
|
30 | 17 | self,
|
31 |
| - exc_type: Optional[Type[BaseException]], |
32 |
| - exc_val: Optional[BaseException], |
33 |
| - exc_tb: Optional[TracebackType], |
| 18 | + exc_type: type[BaseException] | None, |
| 19 | + exc_val: BaseException | None, |
| 20 | + exc_tb: TracebackType | None, |
34 | 21 | ) -> bool: ...
|
35 |
| - def format_message(self, default_msg: Text) -> Text: ... |
36 |
| - def add_test(self, cb: Callable[[_E], Any]) -> None: ... |
| 22 | + def format_message(self, default_msg: str) -> str: ... |
| 23 | + def add_test(self, cb: Callable[[_E], object]) -> None: ... |
37 | 24 | @property
|
38 | 25 | def exc_val(self) -> _E: ...
|
39 | 26 |
|
40 | 27 | class AssertRaisesErrnoContext(AssertRaisesContext[_E]):
|
41 | 28 | expected_errno: int
|
42 | 29 | def __init__(
|
43 |
| - self, exception: Type[_E], expected_errno: int, msg_fmt: Text = ... |
| 30 | + self, exception: type[_E], expected_errno: int, msg_fmt: str = ... |
44 | 31 | ) -> None: ...
|
45 | 32 |
|
46 | 33 | class AssertRaisesRegexContext(AssertRaisesContext[_E]):
|
47 |
| - pattern: Text |
| 34 | + pattern: str |
48 | 35 | def __init__(
|
49 |
| - self, exception: Type[_E], pattern: Text, msg_fmt: Text = ... |
| 36 | + self, exception: type[_E], pattern: str, msg_fmt: str = ... |
50 | 37 | ) -> None: ...
|
51 | 38 |
|
52 | 39 | class AssertWarnsContext:
|
53 | 40 | def __init__(
|
54 |
| - self, warning_class: Type[Warning], msg_fmt: Text = ... |
| 41 | + self, warning_class: type[Warning], msg_fmt: str = ... |
55 | 42 | ) -> None: ...
|
56 | 43 | def __enter__(self: _S) -> _S: ...
|
57 | 44 | def __exit__(
|
58 | 45 | self,
|
59 |
| - exc_type: Optional[Type[BaseException]], |
60 |
| - exc_val: Optional[BaseException], |
61 |
| - exc_tb: Optional[TracebackType], |
| 46 | + exc_type: type[BaseException] | None, |
| 47 | + exc_val: BaseException | None, |
| 48 | + exc_tb: TracebackType | None, |
62 | 49 | ) -> None: ...
|
63 |
| - def format_message(self) -> Text: ... |
| 50 | + def format_message(self) -> str: ... |
64 | 51 | def add_test(self, cb: Callable[[Warning], bool]) -> None: ...
|
65 | 52 |
|
66 | 53 | class AssertWarnsRegexContext(AssertWarnsContext):
|
67 |
| - pattern: Text |
| 54 | + pattern: str |
68 | 55 | def __init__(
|
69 |
| - self, warning_class: Type[Warning], msg_fmt: Text = ... |
| 56 | + self, warning_class: type[Warning], msg_fmt: str = ... |
70 | 57 | ) -> None: ...
|
71 | 58 |
|
72 |
| -def fail(msg: Text = ...) -> NoReturn: ... |
73 |
| -def assert_true(expr: Any, msg_fmt: Text = ...) -> None: ... |
74 |
| -def assert_false(expr: Any, msg_fmt: Text = ...) -> None: ... |
75 |
| -def assert_boolean_true(expr: Any, msg_fmt: Text = ...) -> None: ... |
76 |
| -def assert_boolean_false(expr: Any, msg_fmt: Text = ...) -> None: ... |
77 |
| -def assert_is_none(expr: Any, msg_fmt: Text = ...) -> None: ... |
78 |
| -def assert_is_not_none(expr: Any, msg_fmt: Text = ...) -> None: ... |
79 |
| -def assert_equal(first: Any, second: Any, msg_fmt: Text = ...) -> None: ... |
80 |
| -def assert_not_equal(first: Any, second: Any, msg_fmt: Text = ...) -> None: ... |
| 59 | +def fail(msg: str = ...) -> NoReturn: ... |
| 60 | +def assert_true(expr: object, msg_fmt: str = ...) -> None: ... |
| 61 | +def assert_false(expr: object, msg_fmt: str = ...) -> None: ... |
| 62 | +def assert_boolean_true(expr: object, msg_fmt: str = ...) -> None: ... |
| 63 | +def assert_boolean_false(expr: object, msg_fmt: str = ...) -> None: ... |
| 64 | +def assert_is_none(expr: object, msg_fmt: str = ...) -> None: ... |
| 65 | +def assert_is_not_none(expr: object, msg_fmt: str = ...) -> None: ... |
| 66 | +def assert_equal( |
| 67 | + first: object, second: object, msg_fmt: str = ... |
| 68 | +) -> None: ... |
| 69 | +def assert_not_equal( |
| 70 | + first: object, second: object, msg_fmt: str = ... |
| 71 | +) -> None: ... |
81 | 72 | def assert_almost_equal(
|
82 | 73 | first: float,
|
83 | 74 | second: float,
|
84 |
| - msg_fmt: Text = ..., |
| 75 | + msg_fmt: str = ..., |
85 | 76 | places: int = ...,
|
86 | 77 | delta: float = ...,
|
87 | 78 | ) -> None: ...
|
88 | 79 | def assert_not_almost_equal(
|
89 | 80 | first: float,
|
90 | 81 | second: float,
|
91 |
| - msg_fmt: Text = ..., |
| 82 | + msg_fmt: str = ..., |
92 | 83 | places: int = ...,
|
93 | 84 | delta: float = ...,
|
94 | 85 | ) -> None: ...
|
95 | 86 | def assert_dict_equal(
|
96 | 87 | first: dict,
|
97 | 88 | second: dict,
|
98 |
| - key_msg_fmt: Text = ..., |
99 |
| - value_msg_fmt: Text = ..., |
| 89 | + key_msg_fmt: str = ..., |
| 90 | + value_msg_fmt: str = ..., |
100 | 91 | ) -> None: ...
|
101 | 92 | def assert_dict_superset(
|
102 | 93 | first: dict,
|
103 | 94 | second: dict,
|
104 |
| - key_msg_fmt: Text = ..., |
105 |
| - value_msg_fmt: Text = ..., |
106 |
| -) -> None: ... |
107 |
| -def assert_less(first: Any, second: Any, msg_fmt: Text = ...) -> None: ... |
108 |
| -def assert_less_equal( |
109 |
| - first: Any, second: Any, msg_fmt: Text = ... |
| 95 | + key_msg_fmt: str = ..., |
| 96 | + value_msg_fmt: str = ..., |
110 | 97 | ) -> None: ...
|
111 |
| -def assert_greater(first: Any, second: Any, msg_fmt: Text = ...) -> None: ... |
| 98 | +def assert_less(first: Any, second: Any, msg_fmt: str = ...) -> None: ... |
| 99 | +def assert_less_equal(first: Any, second: Any, msg_fmt: str = ...) -> None: ... |
| 100 | +def assert_greater(first: Any, second: Any, msg_fmt: str = ...) -> None: ... |
112 | 101 | def assert_greater_equal(
|
113 |
| - first: Any, second: Any, msg_fmt: Text = ... |
| 102 | + first: Any, second: Any, msg_fmt: str = ... |
114 | 103 | ) -> None: ...
|
115 | 104 | def assert_regex(
|
116 |
| - text: Text, regex: Union[Text, Pattern[Text]], msg_fmt: Text = ... |
| 105 | + text: str, regex: str | Pattern[str], msg_fmt: str = ... |
| 106 | +) -> None: ... |
| 107 | +def assert_is(first: object, second: object, msg_fmt: str = ...) -> None: ... |
| 108 | +def assert_is_not( |
| 109 | + first: object, second: object, msg_fmt: str = ... |
117 | 110 | ) -> None: ...
|
118 |
| -def assert_is(first: Any, second: Any, msg_fmt: Text = ...) -> None: ... |
119 |
| -def assert_is_not(first: Any, second: Any, msg_fmt: Text = ...) -> None: ... |
120 | 111 | def assert_in(
|
121 |
| - first: Any, second: Container[Any], msg_fmt: Text = ... |
| 112 | + first: Any, second: Container[Any], msg_fmt: str = ... |
122 | 113 | ) -> None: ...
|
123 | 114 | def assert_not_in(
|
124 |
| - first: Any, second: Container[Any], msg_fmt: Text = ... |
| 115 | + first: Any, second: Container[Any], msg_fmt: str = ... |
125 | 116 | ) -> None: ...
|
126 | 117 | def assert_between(
|
127 |
| - lower_bound: Any, upper_bound: Any, expr: Any, msg_fmt: Text = ... |
| 118 | + lower_bound: Any, upper_bound: Any, expr: Any, msg_fmt: str = ... |
128 | 119 | ) -> None: ...
|
129 | 120 | def assert_is_instance(
|
130 |
| - obj: Any, cls: Union[type, Tuple[type, ...]], msg_fmt: Text = ... |
| 121 | + obj: object, cls: type | tuple[type, ...], msg_fmt: str = ... |
131 | 122 | ) -> None: ...
|
132 | 123 | def assert_not_is_instance(
|
133 |
| - obj: Any, cls: Union[type, Tuple[type, ...]], msg_fmt: Text = ... |
| 124 | + obj: object, cls: type | tuple[type, ...], msg_fmt: str = ... |
134 | 125 | ) -> None: ...
|
135 | 126 | def assert_count_equal(
|
136 |
| - sequence1: Iterable[Any], sequence2: Iterable[Any], msg_fmt: Text = ... |
| 127 | + sequence1: Iterable[Any], sequence2: Iterable[Any], msg_fmt: str = ... |
| 128 | +) -> None: ... |
| 129 | +def assert_has_attr( |
| 130 | + obj: object, attribute: str, msg_fmt: str = ... |
137 | 131 | ) -> None: ...
|
138 |
| -def assert_has_attr(obj: Any, attribute: str, msg_fmt: Text = ...) -> None: ... |
139 | 132 | def assert_datetime_about_now(
|
140 |
| - actual: Optional[datetime.datetime], msg_fmt: Text = ... |
| 133 | + actual: datetime.datetime | None, msg_fmt: str = ... |
141 | 134 | ) -> None: ...
|
142 | 135 | def assert_datetime_about_now_utc(
|
143 |
| - actual: Optional[datetime.datetime], msg_fmt: Text = ... |
| 136 | + actual: datetime.datetime | None, msg_fmt: str = ... |
144 | 137 | ) -> None: ...
|
145 | 138 | def assert_raises(
|
146 |
| - exception: Type[BaseException], msg_fmt: Text = ... |
| 139 | + exception: type[BaseException], msg_fmt: str = ... |
147 | 140 | ) -> AssertRaisesContext: ...
|
148 | 141 | def assert_raises_regex(
|
149 |
| - exception: Type[BaseException], |
150 |
| - regex: Union[Text, Pattern[Text]], |
151 |
| - msg_fmt: Text = ..., |
| 142 | + exception: type[BaseException], |
| 143 | + regex: str | Pattern[str], |
| 144 | + msg_fmt: str = ..., |
152 | 145 | ) -> AssertRaisesContext: ...
|
153 | 146 | def assert_raises_errno(
|
154 |
| - exception: Type[BaseException], errno: int, msg_fmt: Text = ... |
| 147 | + exception: type[BaseException], errno: int, msg_fmt: str = ... |
155 | 148 | ) -> AssertRaisesContext: ...
|
156 | 149 | def assert_succeeds(
|
157 |
| - exception: Type[BaseException], msg_fmt: Text = ... |
| 150 | + exception: type[BaseException], msg_fmt: str = ... |
158 | 151 | ) -> ContextManager: ...
|
159 | 152 | def assert_warns(
|
160 |
| - warning_type: Type[Warning], msg_fmt: Text = ... |
| 153 | + warning_type: type[Warning], msg_fmt: str = ... |
161 | 154 | ) -> AssertWarnsContext: ...
|
162 | 155 | def assert_warns_regex(
|
163 |
| - warning_type: Type[Warning], regex: Text, msg_fmt: Text = ... |
| 156 | + warning_type: type[Warning], regex: str, msg_fmt: str = ... |
164 | 157 | ) -> AssertWarnsContext: ...
|
165 | 158 | def assert_json_subset(
|
166 |
| - first: Union[dict, list], second: Union[dict, list, str, bytes] |
| 159 | + first: dict[str, Any] | list[Any], |
| 160 | + second: dict[str, Any] | list[Any] | str | bytes, |
167 | 161 | ) -> None: ...
|
168 | 162 |
|
169 | 163 | class Exists:
|
|
0 commit comments