File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,24 @@ def bad_name(name: str) -> bool:
31
31
32
32
33
33
class BaseModel (pydantic .BaseModel ):
34
+ class Config :
35
+ extra = "forbid"
36
+
37
+ # Set fields set to be all those that are truthy, so only those are expoed with `skip_defaults`
38
+ @property # type: ignore
39
+ def __fields_set__ (self ) -> typing .Set [str ]: # type: ignore
40
+ s = set ()
41
+ for k , v in self .__values__ .items ():
42
+ if v :
43
+ s .add (k )
44
+ return s
45
+
46
+ @__fields_set__ .setter
47
+ def __fields_set__ (self , val : typing .Set [str ]) -> None :
48
+ pass
49
+
34
50
def __repr_args__ (self ) -> pydantic .ReprArgs : # type: ignore
51
+ # Dont show empty valyes
35
52
for k , v in super ().__repr_args__ ():
36
53
if v :
37
54
yield k , v
@@ -58,7 +75,7 @@ def __ior__(self, other: API) -> API:
58
75
return self
59
76
60
77
def json (self , ** kwargs ) -> str :
61
- return super ().json (exclude_none = True , ** kwargs )
78
+ return super ().json (exclude_none = True , skip_defaults = True , ** kwargs )
62
79
63
80
64
81
class Module (BaseModel ):
You can’t perform that action at this time.
0 commit comments