Skip to content

Commit 883da7c

Browse files
committed
chore: update docstrings
1 parent 6ac0a25 commit 883da7c

File tree

33 files changed

+109
-104
lines changed

33 files changed

+109
-104
lines changed

.github/workflows/update_chart_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def update_values_yaml(values_path: Path, diracx_version: str) -> None:
101101

102102

103103
def main() -> None:
104-
"""Main function."""
104+
"""Run the Main."""
105105
parser = argparse.ArgumentParser(
106106
description="Update chart versions for DiracX release"
107107
)

diracx-core/src/diracx/core/config/sources.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""This module implements the logic of the configuration server side.
1+
"""Module to implement the logic of the configuration server side.
22
33
This is where all the backend abstraction and the caching logic takes place.
44
"""
@@ -44,7 +44,7 @@ def is_running_in_async_context():
4444

4545

4646
def _apply_default_scheme(value: str) -> str:
47-
"""Applies the default git+file:// scheme if not present."""
47+
"""Apply the default git+file:// scheme if not present."""
4848
if isinstance(value, str) and "://" not in value:
4949
value = f"git+file://{value}"
5050
return value
@@ -88,14 +88,18 @@ def __init__(self, *, backend_url: ConfigSourceUrl) -> None:
8888

8989
@abstractmethod
9090
def latest_revision(self) -> tuple[str, datetime]:
91-
"""Must return:
91+
"""Abstract method.
92+
93+
Must return:
9294
* a unique hash as a string, representing the last version
9395
* a datetime object corresponding to when the version dates.
9496
"""
9597

9698
@abstractmethod
9799
def read_raw(self, hexsha: str, modified: datetime) -> Config:
98-
"""Return the Config object that corresponds to the
100+
"""Abstract method.
101+
102+
Return the Config object that corresponds to the
99103
specific hash
100104
The `modified` parameter is just added as a attribute to the config.
101105
"""
@@ -114,10 +118,7 @@ def create(cls):
114118
def create_from_url(
115119
cls, *, backend_url: ConfigSourceUrl | Path | str
116120
) -> "ConfigSource":
117-
"""Factory method to produce a concrete instance depending on
118-
the backend URL scheme.
119-
120-
"""
121+
"""Produce a concrete instance depending on the backend URL scheme."""
121122
url = TypeAdapter(ConfigSourceUrl).validate_python(str(backend_url))
122123
return cls.__registry[url.scheme](backend_url=url)
123124

@@ -234,7 +235,8 @@ def get_git_branch_from_url(self, backend_url: ConfigSourceUrl) -> str:
234235

235236

236237
class LocalGitConfigSource(BaseGitConfigSource):
237-
"""The configuration is stored on a local git repository
238+
"""The configuration is stored on a local git repository.
239+
238240
When running on multiple servers, the filesystem must be shared.
239241
"""
240242

diracx-core/src/diracx/core/extensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def select_from_extension(*, group: str, name: str | None = None) -> list[EntryP
6363
def supports_extending(
6464
group: str, name: str
6565
) -> Callable[[Callable[P, T]], Callable[P, T]]:
66-
"""Decorator to replace a function with an extension implementation.
66+
"""Replace a function with an extension implementation.
6767
6868
This decorator looks for an entry point in the specified group and name,
6969
and if found, replaces the decorated function with the extension's implementation.

diracx-core/src/diracx/core/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
"""Models are used to define the data structure of the requests and responses
2-
for the DiracX API. They are shared between the client components (cli, api) and
3-
services components (db, logic, routers).
1+
"""Models used to define the data structure of the requests and responses for the DiracX API.
2+
3+
They are shared between the client components (cli, api) and services components (db, logic, routers).
44
"""
55

66
from __future__ import annotations

diracx-core/src/diracx/core/preferences.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ def validate_log_level(cls, v: str):
5858

5959
@lru_cache(maxsize=1)
6060
def get_diracx_preferences() -> DiracxPreferences:
61-
"""Caches the preferences."""
61+
"""Cache the preferences."""
6262
return DiracxPreferences()

diracx-core/src/diracx/core/properties.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""Just listing the possible Properties
2-
This module contains list of Properties that can be assigned to users and groups.
3-
"""
1+
"""Module containing the list of Properties that can be assigned to users and groups."""
42

53
from __future__ import annotations
64

diracx-core/src/diracx/core/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def __init__(self, data: str):
107107

108108

109109
def _apply_default_scheme(value: str) -> str:
110-
"""Applies the default file:// scheme if not present."""
110+
"""Apply the default file:// scheme if not present."""
111111
if isinstance(value, str) and "://" not in value:
112112
value = f"file://{value}"
113113
return value
@@ -125,7 +125,7 @@ def create(cls) -> Self:
125125

126126
@contextlib.asynccontextmanager
127127
async def lifetime_function(self) -> AsyncIterator[None]:
128-
"""A context manager that can be used to run code at startup and shutdown."""
128+
"""Context manager to run code at startup and shutdown."""
129129
yield
130130

131131

diracx-core/src/diracx/core/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def get(self, key: str, populate_func: Callable[[], T], blocking: bool = True) -
237237
raise NotReadyError(f"Cache key {key} is not ready yet.")
238238

239239
def _work(self, key: str, populate_func: Callable[[], Any]) -> None:
240-
"""Internal method to execute the populate_func and update caches.
240+
"""Execute the populate_func and update caches.
241241
242242
This method is intended to be run in a separate thread. It calls the
243243
populate_func, stores the result in both caches, and cleans up the

diracx-db/src/diracx/db/os/utils.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class OpenSearchDBUnavailableError(DBUnavailableError, OpenSearchDBError):
3030

3131

3232
class BaseOSDB(metaclass=ABCMeta):
33-
"""This should be the base class of all the OpenSearch DiracX DBs.
33+
"""Base class of all the OpenSearch DiracX DBs.
3434
3535
The details covered here should be handled automatically by the service and
3636
task machinery of DiracX and this documentation exists for informational
@@ -121,26 +121,19 @@ def available_urls(cls) -> dict[str, dict[str, Any]]:
121121

122122
@classmethod
123123
def session(cls) -> Self:
124-
"""This is just a fake method such that the Dependency overwrite has
125-
a hash to use.
126-
"""
124+
"""Fake method such that the Dependency overwrite has a hash to use."""
127125
raise NotImplementedError("This should never be called")
128126

129127
@property
130128
def client(self) -> AsyncOpenSearch:
131-
"""Just a getter for _client, making sure we entered
132-
the context manager.
133-
"""
129+
"""Just a getter for _client, making sure we entered the context manager."""
134130
if self._client is None:
135131
raise RuntimeError(f"{self.__class__} was used before entering")
136132
return self._client
137133

138134
@contextlib.asynccontextmanager
139135
async def client_context(self) -> AsyncIterator[None]:
140-
"""Context manage to manage the client lifecycle.
141-
This is called when starting fastapi.
142-
143-
"""
136+
"""Context manager to manage the client lifecycle. This is called when starting fastapi."""
144137
assert self._client is None, "client_context cannot be nested"
145138
async with AsyncOpenSearch(**self._connection_kwargs) as self._client:
146139
try:
@@ -150,6 +143,7 @@ async def client_context(self) -> AsyncIterator[None]:
150143

151144
async def ping(self):
152145
"""Check whether the connection to the DB is still working.
146+
153147
We could enable the ``pre_ping`` in the engine, but this would
154148
be ran at every query.
155149
"""
@@ -159,7 +153,8 @@ async def ping(self):
159153
)
160154

161155
async def __aenter__(self):
162-
"""This is entered on every request.
156+
"""Entered on every request.
157+
163158
At the moment it does nothing, however, we keep it here
164159
in case we ever want to use OpenSearch equivalent of a transaction.
165160
"""

diracx-db/src/diracx/db/sql/auth/db.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ class AuthDB(BaseSQLDB):
3838

3939
@classmethod
4040
async def post_create(cls, conn: AsyncConnection) -> None:
41-
"""Create partitions if it is a MySQL DB and it does not have
41+
"""Create partitions.
42+
43+
If it is a MySQL DB and it does not have
4244
it yet and the table does not have any data yet.
4345
We do this as a post_create step as sqlalchemy does not support
4446
partition so well.
@@ -115,7 +117,7 @@ async def device_flow_validate_user_code(
115117
return (await self.conn.execute(stmt)).scalar_one()
116118

117119
async def get_device_flow(self, device_code: str):
118-
""":raises: NoResultFound"""
120+
"""raise: NoResultFound."""
119121
# The with_for_update
120122
# prevents that the token is retrieved
121123
# multiple time concurrently
@@ -137,7 +139,7 @@ async def update_device_flow_status(
137139
async def device_flow_insert_id_token(
138140
self, user_code: str, id_token: dict[str, str], max_validity: int
139141
) -> None:
140-
""":raises: AuthorizationError if no such code or status not pending"""
142+
"""raise: AuthorizationError if no such code or status not pending."""
141143
stmt = update(DeviceFlows)
142144
stmt = stmt.where(
143145
DeviceFlows.user_code == user_code,
@@ -211,7 +213,8 @@ async def insert_authorization_flow(
211213
async def authorization_flow_insert_id_token(
212214
self, uuid: str, id_token: dict[str, str], max_validity: int
213215
) -> tuple[str, str]:
214-
"""Returns code, redirect_uri
216+
"""Return code, redirect_uri.
217+
215218
:raises: AuthorizationError if no such uuid or status not pending.
216219
"""
217220
# Hash the code to avoid leaking information
@@ -268,8 +271,9 @@ async def insert_refresh_token(
268271
subject: str,
269272
scope: str,
270273
) -> None:
271-
"""Insert a refresh token in the DB as well as user attributes
272-
required to generate access tokens.
274+
"""Insert a refresh token in the DB.
275+
276+
As well as user attributes required to generate access tokens.
273277
"""
274278
# Insert values into the DB
275279
stmt = insert(RefreshTokens).values(

0 commit comments

Comments
 (0)