Skip to content
Snippets Groups Projects
Commit 08c02683 authored by DAVID Axel's avatar DAVID Axel
Browse files

refactor: :recycle: Use LowercaseStrEnum instead of Enum

parent 1c7e6b93
No related branches found
No related tags found
No related merge requests found
...@@ -73,7 +73,6 @@ def __fallback() -> str: ...@@ -73,7 +73,6 @@ def __fallback() -> str:
error_text error_text
str str
""" """
return "OOPS! Nothing was found here!" return "OOPS! Nothing was found here!"
......
...@@ -47,7 +47,6 @@ class VigenereAPIOpenAPIHandler(OpenAPIHandler): ...@@ -47,7 +47,6 @@ class VigenereAPIOpenAPIHandler(OpenAPIHandler):
VersionTypeError VersionTypeError
Thrown if 'version' is not a Version object. Thrown if 'version' is not a Version object.
""" """
if not isinstance(version, Version): if not isinstance(version, Version):
raise VersionTypeError(version) raise VersionTypeError(version)
......
...@@ -44,7 +44,6 @@ def get_route_filter(excluded: Collection[str]) -> Callable[[str, Route], bool]: ...@@ -44,7 +44,6 @@ def get_route_filter(excluded: Collection[str]) -> Callable[[str, Route], bool]:
filter filter
Callable[[str, Route], bool] Callable[[str, Route], bool]
""" """
if not isinstance(excluded, Collection): if not isinstance(excluded, Collection):
raise ExcludedPathsTypeError(excluded) raise ExcludedPathsTypeError(excluded)
...@@ -78,7 +77,6 @@ def get_route_filter(excluded: Collection[str]) -> Callable[[str, Route], bool]: ...@@ -78,7 +77,6 @@ def get_route_filter(excluded: Collection[str]) -> Callable[[str, Route], bool]:
route_shown route_shown
bool bool
""" """
if not isinstance(path, str): if not isinstance(path, str):
raise PathTypeError(path) raise PathTypeError(path)
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
"""The caesar controller's documentation.""" """The caesar controller's documentation."""
from dataclasses import dataclass from dataclasses import dataclass
from enum import Enum, unique from enum import auto, unique
from http import HTTPStatus from http import HTTPStatus
from typing import final from typing import final
...@@ -30,17 +30,17 @@ from blacksheep.server.openapi.common import ( ...@@ -30,17 +30,17 @@ from blacksheep.server.openapi.common import (
ResponseInfo, ResponseInfo,
) )
from strenum import LowercaseStrEnum
from vigenere_api.models import CaesarData from vigenere_api.models import CaesarData
@final @final
@unique @unique
class CaesarOperation(Enum): class CaesarOperation(LowercaseStrEnum):
"""All Caesar operations.""" """All Caesar operations."""
value: str CIPHER = auto()
CIPHER = "cipher" DECIPHER = auto()
DECIPHER = "decipher"
CAESAR_DATA1 = ( CAESAR_DATA1 = (
......
...@@ -19,4 +19,5 @@ ...@@ -19,4 +19,5 @@
from .errors import VigenereAPITypeError from .errors import VigenereAPITypeError
from .model import Model from .model import Model
__all__ = ["Model", "VigenereAPITypeError"] __all__ = ["Model", "VigenereAPITypeError"]
...@@ -23,6 +23,7 @@ from typing import final, Union ...@@ -23,6 +23,7 @@ from typing import final, Union
from pydantic import StrictInt, StrictStr, validator from pydantic import StrictInt, StrictStr, validator
from vigenere_api.helpers import Model from vigenere_api.helpers import Model
from .errors import ( from .errors import (
AlgorithmKeyTypeError, AlgorithmKeyTypeError,
AlgorithmTextTypeError, AlgorithmTextTypeError,
...@@ -35,6 +36,7 @@ from .errors import ( ...@@ -35,6 +36,7 @@ from .errors import (
) )
from .helper import move_char from .helper import move_char
Key = Union[StrictInt, StrictStr] Key = Union[StrictInt, StrictStr]
......
...@@ -21,6 +21,7 @@ from typing import final ...@@ -21,6 +21,7 @@ from typing import final
from pydantic import validator from pydantic import validator
from vigenere_api.helpers import Model from vigenere_api.helpers import Model
from .errors import ( from .errors import (
InvalidMajorValueError, InvalidMajorValueError,
InvalidMinorValueError, InvalidMinorValueError,
...@@ -141,7 +142,6 @@ class Version(Model): ...@@ -141,7 +142,6 @@ class Version(Model):
version version
str str
""" """
return f"{self.major}.{self.minor}.{self.patch}" return f"{self.major}.{self.minor}.{self.patch}"
...@@ -154,5 +154,4 @@ def get_version() -> Version: ...@@ -154,5 +154,4 @@ def get_version() -> Version:
version version
Version Version
""" """
return Version(major=1, minor=0, patch=0) return Version(major=1, minor=0, patch=0)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment