|
1 | 1 | import collections |
2 | 2 | import inspect |
3 | 3 | from collections import OrderedDict |
4 | | -from collections.abc import Generator, Iterable |
| 4 | +from collections.abc import Callable, Generator, Iterable |
5 | 5 | from types import ( |
6 | 6 | FunctionType, |
7 | 7 | GeneratorType, |
|
10 | 10 | from typing import ( |
11 | 11 | TYPE_CHECKING, |
12 | 12 | Any, |
13 | | - Callable, |
14 | 13 | NamedTuple, |
15 | 14 | Optional, |
16 | | - Union, |
17 | 15 | ) |
18 | 16 |
|
19 | 17 | from syrupy.constants import ( |
|
41 | 39 | IterableEntries = tuple[ |
42 | 40 | Iterable["PropertyName"], |
43 | 41 | "PropertyValueGetter", |
44 | | - Optional["PropertyValueFilter"], |
| 42 | + "PropertyValueFilter" | None, |
45 | 43 | ] |
46 | 44 |
|
47 | 45 |
|
@@ -240,7 +238,7 @@ def _serialize( |
240 | 238 | include: Optional["PropertyFilter"] = None, |
241 | 239 | matcher: Optional["PropertyMatcher"] = None, |
242 | 240 | path: "PropertyPath" = (), |
243 | | - visited: Optional[set[Any]] = None, |
| 241 | + visited: set[Any] | None = None, |
244 | 242 | ) -> str: |
245 | 243 | visited = set() if visited is None else visited |
246 | 244 | data_id = id(data) |
@@ -276,7 +274,7 @@ def _serialize( |
276 | 274 |
|
277 | 275 | @classmethod |
278 | 276 | def serialize_number( |
279 | | - cls, data: Union[int, float], *, depth: int = 0, **kwargs: Any |
| 277 | + cls, data: int | float, *, depth: int = 0, **kwargs: Any |
280 | 278 | ) -> str: |
281 | 279 | return cls.__serialize_plain(data=data, depth=depth) |
282 | 280 |
|
@@ -424,13 +422,13 @@ def serialize_custom_iterable( |
424 | 422 | *, |
425 | 423 | data: "SerializableData", |
426 | 424 | resolve_entries: "IterableEntries", |
427 | | - open_paren: Optional[str] = None, |
428 | | - close_paren: Optional[str] = None, |
| 425 | + open_paren: str | None = None, |
| 426 | + close_paren: str | None = None, |
429 | 427 | depth: int = 0, |
430 | 428 | exclude: Optional["PropertyFilter"] = None, |
431 | 429 | include: Optional["PropertyFilter"] = None, |
432 | 430 | path: "PropertyPath" = (), |
433 | | - separator: Optional[str] = None, |
| 431 | + separator: str | None = None, |
434 | 432 | serialize_key: bool = False, |
435 | 433 | **kwargs: Any, |
436 | 434 | ) -> str: |
@@ -507,7 +505,7 @@ class AmberDataSerializerSorted(AmberDataSerializer): |
507 | 505 | VERSION = f"{AmberDataSerializer.VERSION}-sorted" |
508 | 506 |
|
509 | 507 | @classmethod |
510 | | - def __maybe_int(cls, part: str) -> tuple[int, Union[str, int]]: |
| 508 | + def __maybe_int(cls, part: str) -> tuple[int, str | int]: |
511 | 509 | try: |
512 | 510 | # cast to int only if the string is the exact representation of the int |
513 | 511 | # for example, '012' != str(int('012')) |
|
0 commit comments