Skip to content

Commit

Permalink
Fix strenum import for newer pythons
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangreen committed Nov 13, 2024
1 parent 2ae2600 commit 2612ca7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/palace/manager/opds/opds2.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import annotations

import sys
from collections.abc import Sequence
from enum import auto
from functools import cached_property
from typing import Annotated, Any, Generic, TypeVar

from backports.strenum.strenum import StrEnum
from pydantic import (
AwareDatetime,
Field,
Expand All @@ -27,6 +27,12 @@
from palace.manager.opds.util import StrOrTuple, obj_or_tuple_to_tuple
from palace.manager.util.datetime_helpers import utc_now

# TODO: Remove this when we drop support for Python 3.10
if sys.version_info >= (3, 11):
from enum import StrEnum
else:
from backports.strenum import StrEnum


def validate_self_link(value: CompactCollection[LinkT]) -> CompactCollection[LinkT]:
"""
Expand Down
9 changes: 8 additions & 1 deletion src/palace/manager/opds/palace.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
from backports.strenum import StrEnum
import sys

from pydantic import Field, field_validator

from palace.manager.opds.base import BaseOpdsModel
from palace.manager.util.log import LoggerMixin

# TODO: Remove this when we drop support for Python 3.10
if sys.version_info >= (3, 11):
from enum import StrEnum
else:
from backports.strenum import StrEnum


class PublicationTypes(StrEnum):
"""
Expand Down
8 changes: 7 additions & 1 deletion src/palace/manager/opds/rwpm.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from __future__ import annotations

import sys
from collections.abc import Sequence
from datetime import date
from enum import auto
from functools import cached_property
from typing import Literal, TypeVar

from backports.strenum import StrEnum
from pydantic import AwareDatetime, Field, NonNegativeInt, PositiveFloat, PositiveInt

from palace.manager.opds.base import BaseOpdsModel
Expand All @@ -19,6 +19,12 @@
obj_or_tuple_to_tuple,
)

# TODO: Remove this when we drop support for Python 3.10
if sys.version_info >= (3, 11):
from enum import StrEnum
else:
from backports.strenum import StrEnum


class Encryption(BaseOpdsModel):
"""
Expand Down

0 comments on commit 2612ca7

Please sign in to comment.