@@ -566,9 +566,9 @@ def _is_child_field(cls, field_name: str) -> bool:
566
566
567
567
# Check if the type of the field is a list or dict
568
568
collection_arg = None
569
- if get_origin (f .type ) == list and len (get_args (f .type )) > 0 :
569
+ if get_origin (f .type ) is list and len (get_args (f .type )) > 0 :
570
570
collection_arg = get_args (f .type )[0 ]
571
- elif get_origin (f .type ) == dict and len (get_args (f .type )) > 0 :
571
+ elif get_origin (f .type ) is dict and len (get_args (f .type )) > 0 :
572
572
collection_arg = get_args (f .type )[1 ]
573
573
574
574
try :
@@ -641,16 +641,16 @@ def _is_base_type(
641
641
value = get_origin (value )
642
642
643
643
return (
644
- value == int
645
- or value == str
646
- or value == bool
647
- or value == float
648
- or (can_be_list and value == list )
649
- or (can_be_dict and value == dict )
650
- or (can_be_ndarray and value == numpy .ndarray )
644
+ value is int
645
+ or value is str
646
+ or value is bool
647
+ or value is float
648
+ or (can_be_list and value is list )
649
+ or (can_be_dict and value is dict )
650
+ or (can_be_ndarray and value is numpy .ndarray )
651
651
or (can_be_none and value is None )
652
652
or (can_be_eval_expr and cls ._is_evaluable_expression (value ))
653
- or value == Union
653
+ or value is Union
654
654
)
655
655
656
656
@staticmethod
@@ -671,11 +671,11 @@ def _type_to_str(type_: Any) -> str:
671
671
672
672
# If its a Generic type
673
673
elif get_origin (type_ ) is not None :
674
- if get_origin (type_ ) == list and len (get_args (type_ )) > 0 :
674
+ if get_origin (type_ ) is list and len (get_args (type_ )) > 0 :
675
675
return Base ._type_to_str (get_args (type_ )[0 ])
676
- elif get_origin (type_ ) == dict and len (get_args (type_ )) > 0 :
676
+ elif get_origin (type_ ) is dict and len (get_args (type_ )) > 0 :
677
677
return Base ._type_to_str (get_args (type_ )[1 ])
678
- elif get_origin (type_ ) == Union and len (get_args (type_ )) > 0 :
678
+ elif get_origin (type_ ) is Union and len (get_args (type_ )) > 0 :
679
679
return (
680
680
"Union["
681
681
+ ", " .join ([Base ._type_to_str (arg ) for arg in get_args (type_ )])
@@ -916,9 +916,9 @@ def insert_links(text, format=MARKDOWN_FORMAT):
916
916
table_info .append ([n , t , d ])
917
917
918
918
# Get the contained type
919
- if get_origin (type_ ) == list and len (get_args (type_ )) > 0 :
919
+ if get_origin (type_ ) is list and len (get_args (type_ )) > 0 :
920
920
referenced .append (get_args (type_ )[0 ])
921
- elif get_origin (type_ ) == dict and len (get_args (type_ )) > 1 :
921
+ elif get_origin (type_ ) is dict and len (get_args (type_ )) > 1 :
922
922
referenced .append (get_args (type_ )[1 ])
923
923
else :
924
924
referenced .append (type_ )
@@ -1080,7 +1080,7 @@ def _is_list_base(cl):
1080
1080
Check if a class is a list of Base objects. These will be serialized as dicts if the underlying class has an id
1081
1081
attribute.
1082
1082
"""
1083
- return get_origin (cl ) == list and issubclass (get_args (cl )[0 ], Base )
1083
+ return get_origin (cl ) is list and issubclass (get_args (cl )[0 ], Base )
1084
1084
1085
1085
1086
1086
converter .register_unstructure_hook_factory (_is_list_base , _unstructure_list_base )
0 commit comments