@@ -12,14 +12,12 @@ def parse_json_fields(cls, json):
1212 return tuple (map (Field .parse_json , json .get ('fields' , []))) or None # Note: DFS Field construction
1313
1414 @classmethod
15- def parse_json (cls , json , fields = None ):
15+ def parse_json (cls , json ):
1616 if 'type' not in json :
1717 raise ValueError ('No type found in json' )
1818 type_str = json ['type' ]
19- if fields is None and json .get ('fields' ) is not None :
20- fields = cls .parse_json_fields (json )
2119 for field_type in cls .FIELD_TYPES :
22- maybe_type = field_type .parse_json (json , fields = fields )
20+ maybe_type = field_type .parse_json (json )
2321 if maybe_type is not None :
2422 return maybe_type
2523 else :
@@ -42,7 +40,7 @@ def parse_versions(cls, versions):
4240 else :
4341 return tuple (map (int , versions .split ('-' )))
4442
45- def __init__ (self , json , fields = None ):
43+ def __init__ (self , json ):
4644 self ._json = json
4745 self ._name = json ['name' ]
4846 # versions tells when to include the field in encode / decode
@@ -63,9 +61,10 @@ def __init__(self, json, fields=None):
6361 self ._flexible_versions = self .parse_versions (json .get ('flexibleVersions' ))
6462 self ._nullable_versions = self .parse_versions (json .get ('nullableVersions' ))
6563 self ._type_str = json ['type' ]
66- if fields is None and json .get ('fields' ) is not None :
67- fields = self .parse_json_fields (json )
68- self ._fields = fields
64+ if 'fields' in json :
65+ self ._fields = self .parse_json_fields (json )
66+ else :
67+ self ._fields = None
6968 self ._ignorable = json .get ('ignorable' )
7069 self ._entity_type = json .get ('entityType' )
7170 self ._about = json .get ('about' , '' )
0 commit comments