1+ from collections .abc import Iterable
12from enum import Enum
2- from typing import Any , Dict , FrozenSet , Iterable , List , Optional , Tuple , TypedDict
3+ from typing import Any , TypedDict
34
45
56class ExtractFrom (str , Enum ):
@@ -18,48 +19,48 @@ class ExtractFrom(str, Enum):
1819class _Selector (TypedDict , total = False ):
1920 type : str
2021 value : str
21- state : Optional [ str ]
22+ state : str | None
2223
2324
2425class Action (TypedDict , total = False ):
2526 action : str
26- address : Optional [ dict ]
27- args : Optional [ dict ]
28- button : Optional [ str ]
29- delay : Optional [ float ]
30- id : Optional [ str ]
31- key : Optional [ str ]
32- keyword : Optional [ str ]
33- left : Optional [ int ]
34- maxPageHeight : Optional [ int ]
35- maxScrollCount : Optional [ int ]
36- maxScrollDelay : Optional [ float ]
37- onError : Optional [ str ]
38- options : Optional [ dict ]
39- selector : Optional [ _Selector ]
40- source : Optional [ str ]
41- text : Optional [ str ]
42- timeout : Optional [ float ]
43- top : Optional [ int ]
44- url : Optional [ str ]
45- urlMatchingOptions : Optional [ str ]
46- urlPattern : Optional [ str ]
47- values : Optional [ List [ str ]]
48- waitForNavigationTimeout : Optional [ float ]
49- waitUntil : Optional [ str ]
27+ address : dict | None
28+ args : dict | None
29+ button : str | None
30+ delay : float | None
31+ id : str | None
32+ key : str | None
33+ keyword : str | None
34+ left : int | None
35+ maxPageHeight : int | None
36+ maxScrollCount : int | None
37+ maxScrollDelay : float | None
38+ onError : str | None
39+ options : dict | None
40+ selector : _Selector | None
41+ source : str | None
42+ text : str | None
43+ timeout : float | None
44+ top : int | None
45+ url : str | None
46+ urlMatchingOptions : str | None
47+ urlPattern : str | None
48+ values : list [ str ] | None
49+ waitForNavigationTimeout : float | None
50+ waitUntil : str | None
5051
5152
5253class _ActionResult (TypedDict , total = False ):
5354 action : str
5455 elapsedTime : float
5556 status : str
56- error : Optional [ str ]
57+ error : str | None
5758
5859
5960def make_hashable (obj : Any ) -> Any :
6061 """Converts input into hashable form, to use in ``Annotated``."""
6162 if isinstance (obj , (tuple , list )):
62- return tuple (( make_hashable (e ) for e in obj ) )
63+ return tuple (make_hashable (e ) for e in obj )
6364
6465 if isinstance (obj , dict ):
6566 return frozenset ((make_hashable (k ), make_hashable (v )) for k , v in obj .items ())
@@ -78,15 +79,15 @@ def _from_hashable(obj: Any) -> Any:
7879 return obj
7980
8081
81- def actions (value : Iterable [Action ]) -> Tuple [Any , ...]:
82+ def actions (value : Iterable [Action ]) -> tuple [Any , ...]:
8283 """Convert an iterable of :class:`~scrapy_zyte_api.Action` dicts into a hashable value."""
8384 # both lists and dicts are not hashable and we need dep types to be hashable
8485 return tuple (make_hashable (action ) for action in value )
8586
8687
8788def custom_attrs (
88- input : Dict [str , Any ], options : Optional [ Dict [ str , Any ]] = None
89- ) -> Tuple [ FrozenSet [Any ], Optional [ FrozenSet [ Any ]] ]:
89+ input : dict [str , Any ], options : dict [ str , Any ] | None = None
90+ ) -> tuple [ frozenset [Any ], frozenset [ Any ] | None ]:
9091 input_wrapped = make_hashable (input )
9192 options_wrapped = make_hashable (options ) if options else None
9293 return input_wrapped , options_wrapped
0 commit comments