diff --git a/karapace/avro_dataclasses/introspect.py b/karapace/avro_dataclasses/introspect.py index 93f3ab9ce..f3a54a420 100644 --- a/karapace/avro_dataclasses/introspect.py +++ b/karapace/avro_dataclasses/introspect.py @@ -98,15 +98,14 @@ def _field_type(field: Field, type_: object) -> AvroType: # pylint: disable=too # Handle enums. if isinstance(type_, type) and issubclass(type_, Enum): - return EnumType( - { - # Conditionally set a default. - **({"default": field.default.value} if field.default is not MISSING else {}), - "name": type_.__name__, - "type": "enum", - "symbols": [value.value for value in type_], - } - ) + enum_dict: EnumType = { + "name": type_.__name__, + "type": "enum", + "symbols": [value.value for value in type_], + } + if field.default is not MISSING: + enum_dict["default"] = field.default.value + return enum_dict # Handle map types. if origin is Mapping: @@ -115,13 +114,14 @@ def _field_type(field: Field, type_: object) -> AvroType: # pylint: disable=too raise UnderspecifiedAnnotation("Key and value types must be specified for map types") if args[0] is not str: raise UnsupportedAnnotation("Key type must be str") - return MapType( - { - "type": "map", - "values": _field_type(field, args[1]), - **({"default": field.default_factory()} if field.default_factory is not MISSING else {}), - } - ) + map_dict: MapType = { + "name": field.name, + "type": "map", + "values": _field_type(field, args[1]), + } + if field.default_factory is not MISSING: + map_dict["default"] = field.default_factory() + return map_dict raise NotImplementedError( f"Found an unknown type {type_!r} while assembling Avro schema for the field " diff --git a/mypy.ini b/mypy.ini index 38fe8c48a..15ab9042f 100644 --- a/mypy.ini +++ b/mypy.ini @@ -14,7 +14,6 @@ warn_unused_ignores = True warn_no_return = True warn_unreachable = True strict_equality = True -enable_incomplete_feature = Unpack [mypy-karapace.schema_registry_apis] ignore_errors = True