@@ -671,6 +671,33 @@ def make_default(self, py_default: collections.abc.Sequence) -> JSONArray:
671671 return [self .items_schema .make_default (item ) for item in py_default ]
672672
673673
674+ @register_schema
675+ class SetSchema (SequenceSchema ):
676+ """An Avro array schema for a given Python set"""
677+
678+ @classmethod
679+ def handles_type (cls , py_type : type ) -> bool :
680+ """Whether this schema class can represent a given Python class"""
681+ py_type = _type_from_annotated (py_type )
682+ origin = get_origin (py_type )
683+ return _is_class (origin , collections .abc .MutableSet )
684+
685+ def __init__ (
686+ self ,
687+ py_type : type [collections .abc .MutableSet ],
688+ namespace : str | None = None ,
689+ options : Option = Option (0 ),
690+ ):
691+ """
692+ An Avro array schema for a given Python sequence
693+
694+ :param py_type: The Python class to generate a schema for.
695+ :param namespace: The Avro namespace to add to schemas.
696+ :param options: Schema generation options.
697+ """
698+ super ().__init__ (py_type , namespace = namespace , options = options ) # type: ignore
699+
700+
674701@register_schema
675702class DictSchema (Schema ):
676703 """An Avro map schema for a given Python mapping"""
@@ -1148,7 +1175,7 @@ def _record_field(self, py_field: tuple[str, Type]) -> RecordField:
11481175 if field := self .signature_fields .get (name ):
11491176 _annotation , _default = field
11501177 if actual_type is _annotation :
1151- default = _default
1178+ default = _default or dataclasses . MISSING
11521179 field_obj = RecordField (
11531180 py_type = actual_type ,
11541181 name = name ,
0 commit comments