Skip to content

Commit

Permalink
Add typing in legalhold.py
Browse files Browse the repository at this point in the history
Signed-off-by: Bala.FA <[email protected]>
  • Loading branch information
balamurugana committed Dec 3, 2023
1 parent 715a4d3 commit 329373b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions minio/legalhold.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,34 @@

"""Request/response of PutObjectLegalHold and GetObjectLegalHold S3 APIs."""

from __future__ import absolute_import
from __future__ import absolute_import, annotations

from typing import Type, TypeVar
from xml.etree import ElementTree as ET

from .xml import Element, SubElement, findtext

A = TypeVar("A", bound="LegalHold")


class LegalHold:
"""Legal hold configuration."""

def __init__(self, status=False):
def __init__(self, status: bool = False):
self._status = status

@property
def status(self):
def status(self) -> bool:
"""Get status."""
return self._status

@classmethod
def fromxml(cls, element):
def fromxml(cls: Type[A], element: ET.Element) -> A:
"""Create new object with values from XML element."""
status = findtext(element, "Status")
return cls(status == "ON")

def toxml(self, element):
def toxml(self, element: ET.Element) -> ET.Element:
"""Convert to XML."""
element = Element("LegalHold")
SubElement(element, "Status", "ON" if self._status is True else "OFF")
Expand Down

0 comments on commit 329373b

Please sign in to comment.