Skip to content

Commit

Permalink
docs(auth.py-core.py): improve attributes description for several cla…
Browse files Browse the repository at this point in the history
…sses
  • Loading branch information
Michele-Alberti committed Dec 31, 2024
1 parent ccc98e9 commit 9bf4236
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
22 changes: 10 additions & 12 deletions dlunch/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ class DataLunchProvider(OAuthProvider):
It is used only if basic authentication is selected in Data-Lunch configuration options.
Attributes:
config (DictConfig): Hydra configuration dictionary.
Args:
config (DictConfig): Hydra configuration dictionary.
login_template (str | None, optional): path to login template. Defaults to None.
Expand All @@ -172,20 +169,21 @@ def __init__(
logout_template: str | None = None,
) -> None:
# Set Hydra config info
self.config = config
self.config: DictConfig = config
"""Hydra configuration dictionary."""

super().__init__(
login_template=login_template, logout_template=logout_template
)

@property
def login_url(self):
"""str: Login url (`/login`)."""
def login_url(self) -> str:
"""Login url (`/login`)."""
return "/login"

@property
def login_handler(self):
"""DataLunchLoginHandler: Data-Lunch custom login handler."""
def login_handler(self) -> DataLunchLoginHandler:
"""Data-Lunch custom login handler."""
# Set basic template
DataLunchLoginHandler._login_template = self._login_template
# Set Hydra config info
Expand All @@ -212,8 +210,8 @@ def __init__(self, hashed_password: str) -> None:
len(hashed_password) <= 150
), "hash should have less than 150 chars."
# Attributes
self.hashed_password = hashed_password
"""str: Password hash."""
self.hashed_password: str = hashed_password
"""Password hash."""

def __eq__(self, candidate: str) -> bool:
"""Hashes the candidate string and compares it to the stored hash.
Expand Down Expand Up @@ -323,8 +321,8 @@ def __init__(self, encrypted_password: str) -> None:
len(encrypted_password) <= 150
), "encrypted string should have less than 150 chars."
# Attributes
self.encrypted_password = encrypted_password
"""str: encrypted password."""
self.encrypted_password: str = encrypted_password
"""Encrypted password."""

def __eq__(self, candidate: str) -> bool:
"""Decrypt the candidate string and compares it to the stored encrypted value.
Expand Down
6 changes: 2 additions & 4 deletions dlunch/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,13 @@ class Waiter:
Args:
config (DictConfig| None): Hydra configuration object. Defaults to None.
Attributes:
config (DictConfig| None): Hydra configuration object. None if unset.
Raise:
ValueError: when calling (unmangled) methods, if the configuration is not set.
"""

def __init__(self, config: DictConfig | None = None):
self.config = None
self.config: DictConfig | None = None
"""Hydra configuration object"""

# Define decorator to raise an error if the configuration is not set
def _common_decorator(func):
Expand Down

0 comments on commit 9bf4236

Please sign in to comment.