@@ -100,7 +100,7 @@ def __init__(self, atype: str, other_props: Optional[PropsType] = None) -> None:
100100 raise SchemaParseException (
101101 f"Schema type { atype !r} must be a string, was { type (atype )!r} ."
102102 )
103- elif atype not in VALID_TYPES :
103+ if atype not in VALID_TYPES :
104104 fail_msg = f"{ atype } is not a valid type."
105105 raise SchemaParseException (fail_msg )
106106
@@ -177,8 +177,7 @@ def get_space(self) -> Optional[str]:
177177
178178 if self ._full .find ("." ) > 0 :
179179 return self ._full .rsplit ("." , 1 )[0 ]
180- else :
181- return None
180+ return None
182181
183182
184183class Names :
@@ -215,10 +214,10 @@ def add_name(
215214 if to_add .fullname in VALID_TYPES :
216215 fail_msg = f"{ to_add .fullname } is a reserved type name."
217216 raise SchemaParseException (fail_msg )
218- elif to_add .fullname in self .names :
217+ if to_add .fullname in self .names :
219218 fail_msg = f"The name { to_add .fullname !r} is already in use."
220219 raise SchemaParseException (fail_msg )
221- elif to_add .fullname is None :
220+ if to_add .fullname is None :
222221 fail_msg = f"{ to_add .fullname } is missing, but this is impossible."
223222 raise SchemaParseException (fail_msg )
224223
@@ -240,9 +239,9 @@ def __init__(
240239 # Ensure valid ctor args
241240 if not name :
242241 raise SchemaParseException ("Named Schemas must have a non-empty name." )
243- elif not isinstance (name , str ):
242+ if not isinstance (name , str ):
244243 raise SchemaParseException ("The name property must be a string." )
245- elif namespace is not None and not isinstance (namespace , str ):
244+ if namespace is not None and not isinstance (namespace , str ):
246245 raise SchemaParseException ("The namespace property must be a string." )
247246 if names is None :
248247 raise SchemaParseException ("Must provide Names." )
@@ -284,10 +283,10 @@ def __init__(
284283 if not name :
285284 fail_msg = "Fields must have a non-empty name."
286285 raise SchemaParseException (fail_msg )
287- elif not isinstance (name , str ):
286+ if not isinstance (name , str ):
288287 fail_msg = "The name property must be a string." # type: ignore[unreachable]
289288 raise SchemaParseException (fail_msg )
290- elif order is not None and order not in VALID_FIELD_SORT_ORDERS :
289+ if order is not None and order not in VALID_FIELD_SORT_ORDERS :
291290 fail_msg = f"The order property { order } is not valid."
292291 raise SchemaParseException (fail_msg )
293292
@@ -365,9 +364,9 @@ def __init__(
365364 # Ensure valid ctor args
366365 if not isinstance (symbols , list ):
367366 raise AvroException ("Enum Schema requires a JSON array for the symbols property." )
368- elif False in [isinstance (s , str ) for s in symbols ]:
367+ if False in [isinstance (s , str ) for s in symbols ]:
369368 raise AvroException ("Enum Schema requires all symbols to be JSON strings." )
370- elif len (set (symbols )) < len (symbols ):
369+ if len (set (symbols )) < len (symbols ):
371370 raise AvroException (f"Duplicate symbol: { symbols } " )
372371
373372 # Call parent ctor
@@ -457,10 +456,9 @@ def __init__(
457456 and new_schema .type in [schema .type for schema in schema_objects ]
458457 ):
459458 raise SchemaParseException (f"{ new_schema .type } type already in Union" )
460- elif new_schema .type == "union" :
459+ if new_schema .type == "union" :
461460 raise SchemaParseException ("Unions cannot contain other unions." )
462- else :
463- schema_objects .append (new_schema )
461+ schema_objects .append (new_schema )
464462 self ._schemas = schema_objects
465463
466464 # read-only properties
@@ -490,10 +488,9 @@ def make_field_objects(field_data: List[PropsType], names: Names) -> List[Field]
490488 if not (order is None or isinstance (order , str )):
491489 raise SchemaParseException ('"order" must be a string or None' )
492490 doc = field .get ("doc" )
493- if not (doc is None or isinstance (doc , str ) or isinstance ( doc , list )):
491+ if not (doc is None or isinstance (doc , ( list , str ) )):
494492 raise SchemaParseException ('"doc" must be a string, list of strings, or None' )
495- else :
496- doc = cast (Union [str , List [str ], None ], doc )
493+ doc = cast (Union [str , List [str ], None ], doc )
497494 other_props = get_other_props (field , FIELD_RESERVED_PROPS )
498495 new_field = Field (atype , name , has_default , default , order , names , doc , other_props )
499496 parsed_fields [new_field .name ] = field
@@ -583,7 +580,7 @@ def make_avsc_object(json_data: JsonDataType, names: Optional[Names] = None) ->
583580 raise SchemaParseException (
584581 f'"namespace" for type { atype } must be a string or None: { json_data } '
585582 )
586- if not (doc is None or isinstance (doc , str ) or isinstance ( doc , list )):
583+ if not (doc is None or isinstance (doc , ( str , list ) )):
587584 raise SchemaParseException (
588585 f'"doc" for type { atype } must be a string, '
589586 f"a list of strings, or None: { json_data } "
@@ -594,19 +591,15 @@ def make_avsc_object(json_data: JsonDataType, names: Optional[Names] = None) ->
594591 raise SchemaParseException (
595592 f'"symbols" for type enum must be a list of strings: { json_data } '
596593 )
597- else :
598- symbols = cast (List [str ], symbols )
594+ symbols = cast (List [str ], symbols )
599595 return EnumSchema (name , namespace , symbols , names , doc , other_props )
600596 if atype in ["record" , "error" ]:
601597 fields = json_data .get ("fields" , [])
602598 if not isinstance (fields , list ):
603599 raise SchemaParseException (
604- '"fields" for type {} must be a list of mappings: {}' .format (
605- atype , json_data
606- )
600+ f'"fields" for type { atype } must be a list of mappings: { json_data } '
607601 )
608- else :
609- fields = cast (List [PropsType ], fields )
602+ fields = cast (List [PropsType ], fields )
610603 return RecordSchema (name , namespace , fields , names , atype , doc , other_props )
611604 raise SchemaParseException (f"Unknown Named Type: { atype } " )
612605 if atype in VALID_TYPES :
0 commit comments