Skip to content

Commit

Permalink
Use StrEnum instead of subclassing both str and Enum
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisburr committed Sep 27, 2023
1 parent b01493f commit fc80d31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/diracx/core/models.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from __future__ import annotations

from datetime import datetime
from enum import Enum
from enum import StrEnum
from typing import Literal, TypedDict

from pydantic import BaseModel, Field


class ScalarSearchOperator(str, Enum):
class ScalarSearchOperator(StrEnum):
EQUAL = "eq"
NOT_EQUAL = "neq"
GREATER_THAN = "gt"
LESS_THAN = "lt"
LIKE = "like"


class VectorSearchOperator(str, Enum):
class VectorSearchOperator(StrEnum):
IN = "in"
NOT_IN = "not in"

Expand Down Expand Up @@ -49,7 +49,7 @@ class TokenResponse(BaseModel):
refresh_token: str | None


class JobStatus(str, Enum):
class JobStatus(StrEnum):
SUBMITTING = "Submitting"
RECEIVED = "Received"
CHECKING = "Checking"
Expand Down
4 changes: 2 additions & 2 deletions src/diracx/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import re
import secrets
from datetime import timedelta
from enum import Enum
from enum import StrEnum
from typing import Annotated, Literal, TypedDict
from uuid import UUID, uuid4

Expand Down Expand Up @@ -90,7 +90,7 @@ async def require_property(
return Depends(require_property)


class GrantType(str, Enum):
class GrantType(StrEnum):
authorization_code = "authorization_code"
device_code = "urn:ietf:params:oauth:grant-type:device_code"
refresh_token = "refresh_token"
Expand Down

0 comments on commit fc80d31

Please sign in to comment.