Skip to content

Commit

Permalink
refactor: move AppState to types
Browse files Browse the repository at this point in the history
  • Loading branch information
winstxnhdw authored Nov 6, 2024
1 parent 88a760d commit 2a5fd3b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion server/api/v4/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from litestar.params import Parameter

from server.schemas.v1 import Language
from server.state import AppState
from server.types import AppState


@get('/language', sync_to_thread=False, cache=True)
Expand Down
3 changes: 1 addition & 2 deletions server/api/v4/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from litestar.status_codes import HTTP_200_OK

from server.schemas.v1 import Translated, Translation
from server.state import AppState
from server.types import Languages
from server.types import AppState, Languages


class TranslatorController(Controller):
Expand Down
1 change: 1 addition & 0 deletions server/types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from server.types.compute_types import ComputeTypes as ComputeTypes
from server.types.devices import Devices as Devices
from server.types.languages import Languages as Languages
from server.types.state import AppState as AppState
40 changes: 20 additions & 20 deletions server/state.py → server/types/state.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
from litestar.datastructures import State

from server.features.language_detector import LanguageDetector
from server.features.translator import Translator


class AppState(State):
"""
Summary
-------
the Litestar application state that will be injected into the routers
Attributes
----------
language_detector (LanguageDetector) : the language detector
translator (Translator) : the translator
"""

language_detector: LanguageDetector
translator: Translator
from litestar.datastructures import State

from server.features.language_detector import LanguageDetector
from server.features.translator import Translator


class AppState(State):
"""
Summary
-------
the Litestar application state that will be injected into the routers
Attributes
----------
language_detector (LanguageDetector) : the language detector
translator (Translator) : the translator
"""

language_detector: LanguageDetector
translator: Translator

0 comments on commit 2a5fd3b

Please sign in to comment.