diff --git a/pyiceberg/catalog/rest/__init__.py b/pyiceberg/catalog/rest/__init__.py index 5cccddc6b4..c8e2399fe8 100644 --- a/pyiceberg/catalog/rest/__init__.py +++ b/pyiceberg/catalog/rest/__init__.py @@ -20,7 +20,7 @@ import time from collections import deque from collections.abc import Mapping -from enum import Enum +from enum import Enum, StrEnum from typing import ( TYPE_CHECKING, Any, @@ -113,7 +113,7 @@ logger = logging.getLogger(__name__) -class HttpMethod(str, Enum): +class HttpMethod(StrEnum): GET = "GET" HEAD = "HEAD" POST = "POST" diff --git a/pyiceberg/manifest.py b/pyiceberg/manifest.py index 88ca051015..0881273c45 100644 --- a/pyiceberg/manifest.py +++ b/pyiceberg/manifest.py @@ -21,7 +21,7 @@ from abc import ABC, abstractmethod from collections.abc import Callable, Iterator from copy import copy -from enum import Enum +from enum import Enum, StrEnum from types import TracebackType from typing import ( Any, @@ -111,7 +111,7 @@ def __repr__(self) -> str: return f"ManifestEntryStatus.{self.name}" -class FileFormat(str, Enum): +class FileFormat(StrEnum): AVRO = "AVRO" PARQUET = "PARQUET" ORC = "ORC" diff --git a/pyiceberg/table/refs.py b/pyiceberg/table/refs.py index 0cbc11689a..ccb5a6cf99 100644 --- a/pyiceberg/table/refs.py +++ b/pyiceberg/table/refs.py @@ -14,7 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -from enum import Enum +from enum import StrEnum from typing import Annotated from pydantic import Field, model_validator @@ -25,7 +25,7 @@ MAIN_BRANCH = "main" -class SnapshotRefType(str, Enum): +class SnapshotRefType(StrEnum): BRANCH = "branch" TAG = "tag" @@ -33,10 +33,6 @@ def __repr__(self) -> str: """Return the string representation of the SnapshotRefType class.""" return f"SnapshotRefType.{self.name}" - def __str__(self) -> str: - """Return the string representation of the SnapshotRefType class.""" - return self.value - class SnapshotRef(IcebergBaseModel): snapshot_id: int = Field(alias="snapshot-id") diff --git a/pyiceberg/table/snapshots.py b/pyiceberg/table/snapshots.py index 0450df2861..66d3d7f239 100644 --- a/pyiceberg/table/snapshots.py +++ b/pyiceberg/table/snapshots.py @@ -20,7 +20,7 @@ import warnings from collections import defaultdict from collections.abc import Iterable, Mapping -from enum import Enum +from enum import Enum, StrEnum from typing import TYPE_CHECKING, Any from pydantic import Field, PrivateAttr, model_serializer @@ -87,7 +87,7 @@ def __repr__(self) -> str: return f"Operation.{self.name}" -class IsolationLevel(str, Enum): +class IsolationLevel(StrEnum): """Transaction isolation level for concurrent write validation.""" SERIALIZABLE = "serializable"