Skip to content

Commit 0bb8f4b

Browse files
Add missing docstring types
1 parent fc9268a commit 0bb8f4b

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

aiida_restapi/common/query.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,16 @@ def query_params(
5858
"""Parse query parameters into a structured object.
5959
6060
:param filters: AiiDA QueryBuilder filters as JSON string.
61+
:type filters: str | None
6162
:param order_by: Comma-separated string of fields to sort by.
63+
:type order_by: str | None
6264
:param page_size: Number of results per page.
65+
:type page_size: pdt.PositiveInt
6366
:param page: Page number.
67+
:type page: pdt.PositiveInt
6468
:return: Structured query parameters.
65-
:raises HTTPException: If filters cannot be parsed as JSON.
69+
:rtype: QueryParams
70+
:raises HTTPException: If arguments cannot be parsed as JSON.
6671
"""
6772
query_filters: dict[str, t.Any] = {}
6873
query_order_by: str | list[str] | dict[str, t.Any] | None = None

aiida_restapi/models/node.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ class NodeModelRegistry:
121121
"""Registry for AiiDA REST API node models.
122122
123123
This class maintains mappings of node types and their corresponding Pydantic models.
124-
125-
:ivar ModelUnion: A union type of all AiiDA node Pydantic models, discriminated by the `node_type` field.
126124
"""
127125

128126
def __init__(self) -> None:
@@ -136,22 +134,30 @@ def get_node_types(self) -> list[str]:
136134
"""Get the list of registered node class names.
137135
138136
:return: List of node class names.
137+
:rtype: list[str]
139138
"""
140139
return list(self._models.keys())
141140

142141
def get_node_class_name(self, node_type: str) -> str:
143142
"""Get the AiiDA node class name for a given node type.
144143
145144
:param node_type: The AiiDA node type string.
145+
:type node_type: str
146146
:return: The corresponding node class name.
147+
:rtype: str
147148
"""
148149
return node_type.rsplit('.', 2)[-2]
149150

150151
def get_model(self, node_type: str, which: t.Literal['get', 'post'] = 'get') -> type[Node.Model]:
151152
"""Get the Pydantic model class for a given node type.
152153
153154
:param node_type: The AiiDA node type string.
155+
:type node_type: str
156+
:param which: Specify whether to get the 'get' or 'post' model.
154157
:return: The corresponding Pydantic model class.
158+
:rtype: type[Node.Model]
159+
:raises MissingEntryPointError: If the node type is not registered.
160+
:raises KeyError: If the specified model type is unknown.
155161
"""
156162
if (Model := self._models.get(node_type)) is None:
157163
raise MissingEntryPointError(f'Unknown node type: {node_type}')
@@ -163,7 +169,9 @@ def _get_node_post_model(self, node_cls: Node) -> type[Node.Model]:
163169
"""Return a patched Model for the given node class with a literal `node_type` field.
164170
165171
:param node_cls: The AiiDA node class.
172+
:type node_cls: Node
166173
:return: The patched ORM Node model.
174+
:rtype: type[Node.Model]
167175
"""
168176
Model = node_cls.CreateModel
169177
node_type = node_cls.class_node_type
@@ -197,6 +205,7 @@ def _get_post_models(self) -> tuple[type[Node.Model], ...]:
197205
"""Get a union type of all node 'post' models.
198206
199207
:return: A union type of all node 'post' models.
208+
:rtype: tuple[type[Node.Model], ...]
200209
"""
201210
post_models = [model_dict['post'] for model_dict in self._models.values()]
202211
return tuple(post_models)

aiida_restapi/routers/server.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ def _get_route_parts(route: Route) -> tuple[str | None, set[str], str]:
217217
"""Return the parts of a route: path, group, methods, description.
218218
219219
:param route: A FastAPI/Starlette Route object.
220+
:type route: Route
220221
:return: A tuple containing the group, methods, and description of the route.
222+
:rtype: tuple[str | None, set[str], str]
221223
"""
222224
prefix = re.escape(API_CONFIG['PREFIX'])
223225
match = re.match(rf'^{prefix}/([^/]+)/?.*', route.path)

aiida_restapi/routers/submit.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def process_inputs(inputs: dict[str, t.Any]) -> dict[str, t.Any]:
2424
A node UUID is indicated by the key ending with the suffix ``.uuid``.
2525
2626
:param inputs: The inputs dictionary.
27+
:type inputs: dict[str, t.Any]
2728
:returns: The deserialized inputs dictionary.
29+
:rtype: dict[str, t.Any]
2830
"""
2931
uuid_suffix = '.uuid'
3032
results = {}
@@ -61,7 +63,9 @@ def validate_inputs(cls, inputs: dict[str, t.Any]) -> dict[str, t.Any]:
6163
"""Process the inputs dictionary.
6264
6365
:param inputs: The inputs to validate.
66+
:type inputs: dict[str, t.Any]
6467
:returns: The validated inputs.
68+
:rtype: dict[str, t.Any]
6569
"""
6670
return process_inputs(inputs)
6771

0 commit comments

Comments
 (0)