Debian Codegraph @

src/syrupy/types.py

raw
1 # noqa: A005
2 from collections.abc import Callable, Hashable
3 from typing import (
4 Any,
5 )
6
7 SnapshotIndex = int | str
8 SerializableData = Any
9 SerializedData = str | bytes
10 PropertyName = Hashable
11 PropertyValueType = type[SerializableData]
12 PropertyPathEntry = tuple[PropertyName, PropertyValueType]
13 PropertyPath = tuple[PropertyPathEntry, ...]
14 try:
15 from mypy_extensions import NamedArg
16
17 PropertyMatcher = Callable[
18 [
19 NamedArg(SerializableData, "data"), # noqa: F821
20 NamedArg(PropertyPath, "path"), # noqa: F821
21 ],
22 SerializableData | None,
23 ]
24 PropertyFilter = Callable[
25 [
26 NamedArg(PropertyName, "prop"), # noqa: F821
27 NamedArg(PropertyPath, "path"), # noqa: F821
28 ],
29 bool,
30 ]
31
32 except ImportError:
33 globals()["PropertyMatcher"] = Callable[..., SerializableData | None]
34 globals()["PropertyFilter"] = Callable[..., bool]