@@ -566,9 +566,9 @@ def _is_child_field(cls, field_name: str) -> bool:
566566
567567 # Check if the type of the field is a list or dict
568568 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 :
570570 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 :
572572 collection_arg = get_args (f .type )[1 ]
573573
574574 try :
@@ -641,16 +641,16 @@ def _is_base_type(
641641 value = get_origin (value )
642642
643643 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 )
651651 or (can_be_none and value is None )
652652 or (can_be_eval_expr and cls ._is_evaluable_expression (value ))
653- or value == Union
653+ or value is Union
654654 )
655655
656656 @staticmethod
@@ -671,11 +671,11 @@ def _type_to_str(type_: Any) -> str:
671671
672672 # If its a Generic type
673673 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 :
675675 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 :
677677 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 :
679679 return (
680680 "Union["
681681 + ", " .join ([Base ._type_to_str (arg ) for arg in get_args (type_ )])
@@ -916,9 +916,9 @@ def insert_links(text, format=MARKDOWN_FORMAT):
916916 table_info .append ([n , t , d ])
917917
918918 # 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 :
920920 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 :
922922 referenced .append (get_args (type_ )[1 ])
923923 else :
924924 referenced .append (type_ )
@@ -1080,7 +1080,7 @@ def _is_list_base(cl):
10801080 Check if a class is a list of Base objects. These will be serialized as dicts if the underlying class has an id
10811081 attribute.
10821082 """
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 )
10841084
10851085
10861086converter .register_unstructure_hook_factory (_is_list_base , _unstructure_list_base )
0 commit comments