23
23
"""
24
24
25
25
import re
26
+ from collections .abc import Generator , Iterable
26
27
from datetime import datetime
27
28
from enum import Enum
28
29
from functools import reduce
29
30
from json import loads as json_loads
30
- from typing import Any , Dict , FrozenSet , Generator , Iterable , List , Optional , Tuple , Type , Union
31
+ from typing import Any , Optional , Union
31
32
from urllib .parse import quote as url_quote
32
33
from uuid import UUID
33
34
from warnings import warn
@@ -280,7 +281,7 @@ class HashAlgorithm(str, Enum):
280
281
class _HashTypeRepositorySerializationHelper (serializable .helpers .BaseHelper ):
281
282
""" THIS CLASS IS NON-PUBLIC API """
282
283
283
- __CASES : Dict [ Type [serializable .ViewType ], FrozenSet [HashAlgorithm ]] = dict ()
284
+ __CASES : dict [ type [serializable .ViewType ], frozenset [HashAlgorithm ]] = dict ()
284
285
__CASES [SchemaVersion1Dot0 ] = frozenset ({
285
286
HashAlgorithm .MD5 ,
286
287
HashAlgorithm .SHA_1 ,
@@ -304,7 +305,7 @@ class _HashTypeRepositorySerializationHelper(serializable.helpers.BaseHelper):
304
305
__CASES [SchemaVersion1Dot6 ] = __CASES [SchemaVersion1Dot5 ]
305
306
306
307
@classmethod
307
- def __prep (cls , hts : Iterable ['HashType' ], view : Type [serializable .ViewType ]) -> Generator ['HashType' , None , None ]:
308
+ def __prep (cls , hts : Iterable ['HashType' ], view : type [serializable .ViewType ]) -> Generator ['HashType' , None , None ]:
308
309
cases = cls .__CASES .get (view , ())
309
310
for ht in hts :
310
311
if ht .alg in cases :
@@ -315,8 +316,8 @@ def __prep(cls, hts: Iterable['HashType'], view: Type[serializable.ViewType]) ->
315
316
316
317
@classmethod
317
318
def json_normalize (cls , o : Iterable ['HashType' ], * ,
318
- view : Optional [Type [serializable .ViewType ]],
319
- ** __ : Any ) -> List [Any ]:
319
+ view : Optional [type [serializable .ViewType ]],
320
+ ** __ : Any ) -> list [Any ]:
320
321
assert view is not None
321
322
return [
322
323
json_loads (
@@ -328,7 +329,7 @@ def json_normalize(cls, o: Iterable['HashType'], *,
328
329
@classmethod
329
330
def xml_normalize (cls , o : Iterable ['HashType' ], * ,
330
331
element_name : str ,
331
- view : Optional [Type [serializable .ViewType ]],
332
+ view : Optional [type [serializable .ViewType ]],
332
333
xmlns : Optional [str ],
333
334
** __ : Any ) -> XmlElement :
334
335
assert view is not None
@@ -342,7 +343,7 @@ def xml_normalize(cls, o: Iterable['HashType'], *,
342
343
343
344
@classmethod
344
345
def json_denormalize (cls , o : Any ,
345
- ** __ : Any ) -> List ['HashType' ]:
346
+ ** __ : Any ) -> list ['HashType' ]:
346
347
return [
347
348
HashType .from_json ( # type:ignore[attr-defined]
348
349
ht ) for ht in o
@@ -351,14 +352,14 @@ def json_denormalize(cls, o: Any,
351
352
@classmethod
352
353
def xml_denormalize (cls , o : 'XmlElement' , * ,
353
354
default_ns : Optional [str ],
354
- ** __ : Any ) -> List ['HashType' ]:
355
+ ** __ : Any ) -> list ['HashType' ]:
355
356
return [
356
357
HashType .from_xml ( # type:ignore[attr-defined]
357
358
ht , default_ns ) for ht in o
358
359
]
359
360
360
361
361
- _MAP_HASHLIB : Dict [str , HashAlgorithm ] = {
362
+ _MAP_HASHLIB : dict [str , HashAlgorithm ] = {
362
363
# from hashlib.algorithms_guaranteed
363
364
'md5' : HashAlgorithm .MD5 ,
364
365
'sha1' : HashAlgorithm .SHA_1 ,
@@ -593,7 +594,7 @@ class ExternalReferenceType(str, Enum):
593
594
class _ExternalReferenceSerializationHelper (serializable .helpers .BaseHelper ):
594
595
""" THIS CLASS IS NON-PUBLIC API """
595
596
596
- __CASES : Dict [ Type [serializable .ViewType ], FrozenSet [ExternalReferenceType ]] = dict ()
597
+ __CASES : dict [ type [serializable .ViewType ], frozenset [ExternalReferenceType ]] = dict ()
597
598
__CASES [SchemaVersion1Dot1 ] = frozenset ({
598
599
ExternalReferenceType .VCS ,
599
600
ExternalReferenceType .ISSUE_TRACKER ,
@@ -649,7 +650,7 @@ class _ExternalReferenceSerializationHelper(serializable.helpers.BaseHelper):
649
650
}
650
651
651
652
@classmethod
652
- def __normalize (cls , extref : ExternalReferenceType , view : Type [serializable .ViewType ]) -> str :
653
+ def __normalize (cls , extref : ExternalReferenceType , view : type [serializable .ViewType ]) -> str :
653
654
return (
654
655
extref
655
656
if extref in cls .__CASES .get (view , ())
@@ -658,14 +659,14 @@ def __normalize(cls, extref: ExternalReferenceType, view: Type[serializable.View
658
659
659
660
@classmethod
660
661
def json_normalize (cls , o : Any , * ,
661
- view : Optional [Type [serializable .ViewType ]],
662
+ view : Optional [type [serializable .ViewType ]],
662
663
** __ : Any ) -> str :
663
664
assert view is not None
664
665
return cls .__normalize (o , view )
665
666
666
667
@classmethod
667
668
def xml_normalize (cls , o : Any , * ,
668
- view : Optional [Type [serializable .ViewType ]],
669
+ view : Optional [type [serializable .ViewType ]],
669
670
** __ : Any ) -> str :
670
671
assert view is not None
671
672
return cls .__normalize (o , view )
@@ -703,7 +704,7 @@ class XsUri(serializable.helpers.BaseHelper):
703
704
)
704
705
705
706
@staticmethod
706
- def __spec_replace (v : str , r : Tuple [str , str ]) -> str :
707
+ def __spec_replace (v : str , r : tuple [str , str ]) -> str :
707
708
return v .replace (* r )
708
709
709
710
@classmethod
0 commit comments