44from inspect import isclass
55from typing import Annotated
66from typing import Any
7- from typing import Dict
87from typing import Generic
9- from typing import List
108from typing import Optional
11- from typing import Tuple
12- from typing import Type
139from typing import TypeVar
1410from typing import Union
1511from typing import get_args
4137ExternalReference = NewType ("ExternalReference" , str )
4238
4339
44- def validate_model_attribute (model : Type , attribute_base : str ) -> None :
40+ def validate_model_attribute (model : type [ "BaseModel" ] , attribute_base : str ) -> None :
4541 """Validate that an attribute name or a sub-attribute path exist for a
4642 given model."""
4743
@@ -68,7 +64,7 @@ def validate_model_attribute(model: Type, attribute_base: str) -> None:
6864 validate_model_attribute (attribute_type , sub_attribute_base )
6965
7066
71- def extract_schema_and_attribute_base (attribute_urn : str ) -> Tuple [str , str ]:
67+ def extract_schema_and_attribute_base (attribute_urn : str ) -> tuple [str , str ]:
7268 # Extract the schema urn part and the attribute name part from attribute
7369 # name, as defined in :rfc:`RFC7644 §3.10 <7644#section-3.10>`.
7470
@@ -79,8 +75,8 @@ def extract_schema_and_attribute_base(attribute_urn: str) -> Tuple[str, str]:
7975
8076def validate_attribute_urn (
8177 attribute_name : str ,
82- default_resource : Optional [Type ] = None ,
83- resource_types : Optional [List [ Type ]] = None ,
78+ default_resource : Optional [type [ "BaseModel" ] ] = None ,
79+ resource_types : Optional [list [ type [ "BaseModel" ] ]] = None ,
8480) -> str :
8581 """Validate that an attribute urn is valid or not.
8682
@@ -120,7 +116,7 @@ def validate_attribute_urn(
120116 return f"{ schema } :{ attribute_base } "
121117
122118
123- def contains_attribute_or_subattributes (attribute_urns : List [str ], attribute_urn : str ):
119+ def contains_attribute_or_subattributes (attribute_urns : list [str ], attribute_urn : str ):
124120 return attribute_urn in attribute_urns or any (
125121 item .startswith (f"{ attribute_urn } ." ) or item .startswith (f"{ attribute_urn } :" )
126122 for item in attribute_urns
@@ -424,7 +420,7 @@ class BaseModel(PydanticBaseModel):
424420 )
425421
426422 @classmethod
427- def get_field_annotation (cls , field_name : str , annotation_type : Type ) -> Any :
423+ def get_field_annotation (cls , field_name : str , annotation_type : type ) -> Any :
428424 """Return the annotation of type 'annotation_type' of the field
429425 'field_name'."""
430426 field_metadata = cls .model_fields [field_name ].metadata
@@ -440,7 +436,7 @@ def annotation_type_filter(item):
440436 return field_annotation
441437
442438 @classmethod
443- def get_field_root_type (cls , attribute_name : str ) -> Type :
439+ def get_field_root_type (cls , attribute_name : str ) -> type :
444440 """Extract the root type from a model field.
445441
446442 For example, return 'GroupMember' for
@@ -455,7 +451,7 @@ def get_field_root_type(cls, attribute_name: str) -> Type:
455451
456452 # extract 'x' from 'List[x]'
457453 if isclass (get_origin (attribute_type )) and issubclass (
458- get_origin (attribute_type ), List
454+ get_origin (attribute_type ), list
459455 ):
460456 attribute_type = get_args (attribute_type )[0 ]
461457
@@ -727,7 +723,7 @@ def scim_response_serializer(self, value: Any, info: SerializationInfo) -> Any:
727723 @model_serializer (mode = "wrap" )
728724 def model_serializer_exclude_none (
729725 self , handler , info : SerializationInfo
730- ) -> Dict [str , Any ]:
726+ ) -> dict [str , Any ]:
731727 """Remove `None` values inserted by the
732728 :meth:`~scim2_models.base.BaseModel.scim_serializer`."""
733729
@@ -749,8 +745,8 @@ def model_dump(
749745 self ,
750746 * args ,
751747 scim_ctx : Optional [Context ] = Context .DEFAULT ,
752- attributes : Optional [List [str ]] = None ,
753- excluded_attributes : Optional [List [str ]] = None ,
748+ attributes : Optional [list [str ]] = None ,
749+ excluded_attributes : Optional [list [str ]] = None ,
754750 ** kwargs ,
755751 ):
756752 """Create a model representation that can be included in SCIM messages
@@ -834,4 +830,4 @@ def is_complex_attribute(type) -> bool:
834830 )
835831
836832
837- BaseModelType : Type = type (BaseModel )
833+ BaseModelType : type = type (BaseModel )
0 commit comments