@@ -24,13 +24,13 @@ class Config:
2424 allow_mutation = False
2525 extra = "forbid"
2626 json_encoders = {np .ndarray : lambda v : v .flatten ().tolist ()}
27- serialize_default_excludes = set ()
27+ serialize_default_excludes : Set = set ()
2828 serialize_skip_defaults = False
2929 force_skip_defaults = False
3030 canonical_repr = False
3131
3232 @classmethod
33- def parse_raw (cls , data : Union [bytes , str ], * , encoding : str = None ) -> 'Model' :
33+ def parse_raw (cls , data : Union [bytes , str ], * , encoding : str = None ) -> 'ProtoModel' : # type: ignore
3434 """
3535 Parses raw string or bytes into a Model object.
3636
@@ -65,7 +65,7 @@ def parse_raw(cls, data: Union[bytes, str], *, encoding: str = None) -> 'Model':
6565 return cls .parse_obj (obj )
6666
6767 @classmethod
68- def parse_file (cls , path : Union [str , Path ], * , encoding : str = None ) -> 'Model' :
68+ def parse_file (cls , path : Union [str , Path ], * , encoding : str = None ) -> 'ProtoModel' : # type: ignore
6969 """Parses a file into a Model object.
7070
7171 Parameters
@@ -95,15 +95,16 @@ def parse_file(cls, path: Union[str, Path], *, encoding: str = None) -> 'Model':
9595
9696 return cls .parse_raw (path .read_bytes (), encoding = encoding )
9797
98- def dict (self , * args , * *kwargs ) -> Dict [str , Any ]:
98+ def dict (self , ** kwargs ) -> Dict [str , Any ]:
9999 encoding = kwargs .pop ("encoding" , None )
100100
101- kwargs ["exclude" ] = (kwargs .get ("exclude" , None ) or set ()) | self .__config__ .serialize_default_excludes
102- kwargs .setdefault ("skip_defaults" , self .__config__ .serialize_skip_defaults )
103- if self .__config__ .force_skip_defaults :
101+ kwargs ["exclude" ] = (
102+ (kwargs .get ("exclude" , None ) or set ()) | self .__config__ .serialize_default_excludes ) # type: ignore
103+ kwargs .setdefault ("skip_defaults" , self .__config__ .serialize_skip_defaults ) # type: ignore
104+ if self .__config__ .force_skip_defaults : # type: ignore
104105 kwargs ["skip_defaults" ] = True
105106
106- data = super ().dict (* args , * *kwargs )
107+ data = super ().dict (** kwargs )
107108
108109 if encoding is None :
109110 return data
@@ -140,7 +141,7 @@ def serialize(self,
140141
141142 return serialize (data , encoding = encoding )
142143
143- def compare (self , other : 'Model' , ** kwargs ) -> bool :
144+ def compare (self , other : Union [ 'ProtoModel' , BaseModel ] , ** kwargs ) -> bool :
144145 """Compares the current object to the provided object recursively.
145146
146147 Parameters
@@ -158,7 +159,7 @@ def compare(self, other: 'Model', **kwargs) -> bool:
158159 return compare_recursive (self , other , ** kwargs )
159160
160161 def __str__ (self ) -> str : # lgtm: [py/inheritance/incorrect-overridden-signature]
161- if self .__config__ .canonical_repr :
162+ if self .__config__ .canonical_repr : # type: ignore
162163 return super ().to_string ()
163164 else :
164165 return f"{ self .__class__ .__name__ } (ProtoModel)"
0 commit comments