1+ from __future__ import annotations
12import dataclasses
23import datetime
34import inspect
@@ -43,7 +44,7 @@ def convert_from_dict(cls: type, data: dict) -> object:
4344 if data is None :
4445 return data
4546
46- if type (data ) == cls :
47+ if isinstance (data , cls ) :
4748 return data
4849
4950 if dataclasses .is_dataclass (cls ):
@@ -53,7 +54,7 @@ def convert_from_dict(cls: type, data: dict) -> object:
5354 if not ((str (typ ).startswith ('dict[' ) or
5455 str (typ ).startswith ('typing.Dict[' ) or
5556 str (typ ).startswith ('requests.structures.CaseInsensitiveDict[' ) or
56- typ == dict or str (typ ).startswith ('OrderedDict[' ))):
57+ typ is dict or str (typ ).startswith ('OrderedDict[' ))):
5758 data = {}
5859
5960 members = inspect .signature (cls .__init__ ).parameters
@@ -79,7 +80,7 @@ def convert_from_dict(cls: type, data: dict) -> object:
7980 elif (str (typ ).startswith ('dict[' ) or
8081 str (typ ).startswith ('typing.Dict[' ) or
8182 str (typ ).startswith ('requests.structures.CaseInsensitiveDict[' ) or
82- typ == dict or str (typ ).startswith ('OrderedDict[' )):
83+ typ is dict or str (typ ).startswith ('OrderedDict[' )):
8384
8485 values = {}
8586 generic_type = object
@@ -89,7 +90,7 @@ def convert_from_dict(cls: type, data: dict) -> object:
8990 v = data [member ][k ]
9091 values [k ] = get_value (generic_type , v )
9192 kwargs [member ] = values
92- elif typ == inspect .Parameter .empty :
93+ elif typ is inspect .Parameter .empty :
9394 if inspect .Parameter .VAR_KEYWORD == members [member ].kind :
9495 if type (data ) in dict_types :
9596 kwargs .update (data )
@@ -114,7 +115,7 @@ def get_value(typ: type, val: object) -> object:
114115 values .append (converted )
115116 return values
116117 elif str (typ ).startswith ('dict[' ) or str (typ ).startswith (
117- 'typing.Dict[' ) or str (typ ).startswith ('requests.structures.CaseInsensitiveDict[' ) or typ == dict :
118+ 'typing.Dict[' ) or str (typ ).startswith ('requests.structures.CaseInsensitiveDict[' ) or typ is dict :
118119 values = {}
119120 for k in val :
120121 v = val [k ]
0 commit comments