Skip to content

Commit

Permalink
backend: Make post_init_check an instance method (#834)
Browse files Browse the repository at this point in the history
Make post_init_check an instance method
  • Loading branch information
tianjing-li authored Nov 8, 2024
1 parent 4b1b8cd commit 63f80ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
7 changes: 3 additions & 4 deletions src/backend/services/auth/strategies/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@ class BaseOAuthStrategy:
def __init__(self, *args, **kwargs):
self._post_init_check()

@classmethod
def _post_init_check(cls):
def _post_init_check(self):
if any(
[
cls.NAME is None,
self.NAME is None,
]
):
raise ValueError(f"{cls.__name__} must have NAME attribute defined.")
raise ValueError(f"{self.__name__} must have NAME attribute defined.")

@abstractmethod
def get_client_id(self, **kwargs: Any):
Expand Down
16 changes: 7 additions & 9 deletions src/backend/tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ class BaseTool():
def __init__(self, *args, **kwargs):
self._post_init_check()

@classmethod
def _post_init_check(cls):
if cls.ID is None:
raise ValueError(f"{cls.__name__} must have ID attribute defined.")
def _post_init_check(self):
if self.ID is None:
raise ValueError(f"{self.__name__} must have ID attribute defined.")

@classmethod
@abstractmethod
Expand Down Expand Up @@ -68,13 +67,12 @@ def __init__(self, *args, **kwargs):

self._post_init_check()

@classmethod
def _post_init_check(cls):
def _post_init_check(self):
if any(
[
cls.BACKEND_HOST is None,
cls.FRONTEND_HOST is None,
cls.AUTH_SECRET_KEY is None,
self.BACKEND_HOST is None,
self.FRONTEND_HOST is None,
self.AUTH_SECRET_KEY is None,
]
):
raise ValueError(
Expand Down

0 comments on commit 63f80ec

Please sign in to comment.