Skip to content

Commit

Permalink
type more
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Nov 9, 2023
1 parent 519e508 commit 5dd80fa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions minio/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def unmarshal(cls: Type[T], xmlstring: str) -> T:
return cls.fromxml(ET.fromstring(xmlstring))


def getbytes(element) -> bytes:
def getbytes(element: ET.Element) -> bytes:
"""Convert ElementTree.Element to bytes."""
with io.BytesIO() as data:
ET.ElementTree(element).write(
Expand All @@ -108,6 +108,12 @@ def getbytes(element) -> bytes:
return data.getvalue()


def marshal(obj) -> bytes:
class IToXML(Protocol):
@classmethod
def toxml(cls, s: ET.Element | None) -> ET.Element:
...


def marshal(obj: IToXML) -> bytes:
"""Get XML data as bytes of ElementTree.Element."""
return getbytes(obj.toxml(None))

0 comments on commit 5dd80fa

Please sign in to comment.