Skip to content

Commit c300a41

Browse files
authored
Merge pull request #1009 from opsmill/pog-doc501
Add raises section to existing docstrings
2 parents 012bec5 + a186271 commit c300a41

23 files changed

Lines changed: 322 additions & 42 deletions

File tree

docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ If retry_on_failure is True, the query will retry until the server becomes reach
241241
**Raises:**
242242

243243
- `GraphQLError`: When the GraphQL response contains errors.
244+
- `ServerNotReachableError`: If the server is not reachable after exhausting retries.
245+
- `AuthenticationError`: If the server returns a 401 or 403 response.
246+
- `URLNotFoundError`: If the server returns a 404 response.
247+
- `Error`: If the response is unexpectedly missing.
244248

245249
**Returns:**
246250

@@ -286,6 +290,10 @@ Get complete diff tree with metadata and nodes.
286290

287291
Returns None if no diff exists.
288292

293+
**Raises:**
294+
295+
- `ValueError`: If ``from_time`` is later than ``to_time``.
296+
289297
#### `allocate_next_ip_address`
290298

291299
```python
@@ -324,6 +332,10 @@ Allocate a new IP address by using the provided resource pool.
324332

325333
- Node corresponding to the allocated resource.
326334

335+
**Raises:**
336+
337+
- `ValueError`: If ``resource_pool`` is not a ``CoreIPAddressPool``.
338+
327339
</details>
328340
#### `allocate_next_ip_prefix`
329341

@@ -364,6 +376,10 @@ Allocate a new IP prefix by using the provided resource pool.
364376

365377
- Node corresponding to the allocated resource.
366378

379+
**Raises:**
380+
381+
- `ValueError`: If ``resource_pool`` is not a ``CoreIPPrefixPool``.
382+
367383
</details>
368384
#### `create_batch`
369385

@@ -524,6 +540,10 @@ If retry_on_failure is True, the query will retry until the server becomes reach
524540
**Raises:**
525541

526542
- `GraphQLError`: When the GraphQL response contains errors.
543+
- `ServerNotReachableError`: If the server is not reachable after exhausting retries.
544+
- `AuthenticationError`: If the server returns a 401 or 403 response.
545+
- `URLNotFoundError`: If the server returns a 404 response.
546+
- `Error`: If the response is unexpectedly missing.
527547

528548
**Returns:**
529549

@@ -676,6 +696,10 @@ Get complete diff tree with metadata and nodes.
676696

677697
Returns None if no diff exists.
678698

699+
**Raises:**
700+
701+
- `ValueError`: If ``from_time`` is later than ``to_time``.
702+
679703
#### `allocate_next_ip_address`
680704

681705
```python
@@ -714,6 +738,10 @@ Allocate a new IP address by using the provided resource pool.
714738

715739
- Node corresponding to the allocated resource.
716740

741+
**Raises:**
742+
743+
- `ValueError`: If ``resource_pool`` is not a ``CoreIPAddressPool``.
744+
717745
</details>
718746
#### `allocate_next_ip_prefix`
719747

@@ -754,6 +782,10 @@ Allocate a new IP prefix by using the provided resource pool.
754782

755783
- Node corresponding to the allocated resource.
756784

785+
**Raises:**
786+
787+
- `ValueError`: If ``resource_pool`` is not a ``CoreIPPrefixPool``.
788+
757789
</details>
758790
#### `repository_update_commit`
759791

docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ Fetch all nodes that were allocated for the pool and a given resource.
259259

260260
- list\[InfrahubNode]: The allocated nodes.
261261

262+
**Raises:**
263+
264+
- `ValueError`: If the node is not a resource pool.
265+
262266
#### `get_pool_resources_utilization`
263267

264268
```python
@@ -271,19 +275,28 @@ Fetch the utilization of each resource for the pool.
271275

272276
- list\[dict\[str, Any]]: A list containing the allocation numbers for each resource of the pool.
273277

278+
**Raises:**
279+
280+
- `ValueError`: If the node is not a resource pool.
281+
274282
#### `get_flat_value`
275283

276284
```python
277285
get_flat_value(self, key: str, separator: str = '__') -> Any
278286
```
279287

280-
Query recursively a value defined in a flat notation (string), on a hierarchy of objects
288+
Query recursively a value defined in a flat notation (string), on a hierarchy of objects.
281289

282290
**Examples:**
283291

284292
name__value
285293
module.object.value
286294

295+
**Raises:**
296+
297+
- `ValueError`: If ``key`` references an unknown attribute or relationship,
298+
or if a referenced relationship is not of cardinality ``ONE``.
299+
287300
#### `extract`
288301

289302
```python
@@ -544,6 +557,10 @@ Fetch all nodes that were allocated for the pool and a given resource.
544557

545558
- list\[InfrahubNodeSync]: The allocated nodes.
546559

560+
**Raises:**
561+
562+
- `ValueError`: If the node is not a resource pool.
563+
547564
#### `get_pool_resources_utilization`
548565

549566
```python
@@ -556,19 +573,28 @@ Fetch the utilization of each resource for the pool.
556573

557574
- list\[dict\[str, Any]]: A list containing the allocation numbers for each resource of the pool.
558575

576+
**Raises:**
577+
578+
- `ValueError`: If the node is not a resource pool.
579+
559580
#### `get_flat_value`
560581

561582
```python
562583
get_flat_value(self, key: str, separator: str = '__') -> Any
563584
```
564585

565-
Query recursively a value defined in a flat notation (string), on a hierarchy of objects
586+
Query recursively a value defined in a flat notation (string), on a hierarchy of objects.
566587

567588
**Examples:**
568589

569590
name__value
570591
module.object.value
571592

593+
**Raises:**
594+
595+
- `ValueError`: If ``key`` references an unknown attribute or relationship,
596+
or if a referenced relationship is not of cardinality ``ONE``.
597+
572598
#### `extract`
573599

574600
```python

docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/parsers.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ parse_human_friendly_id(hfid: str | list[str]) -> tuple[str | None, list[str]]
1414
```
1515

1616
Parse a human-friendly ID into a kind and an identifier.
17+
18+
**Raises:**
19+
20+
- `ValueError`: If ``hfid`` is neither a string nor a list of strings.

docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ add(self, data: str | RelatedNode | dict) -> None
6565

6666
Add a new peer to this relationship.
6767

68+
**Raises:**
69+
70+
- `UninitializedError`: If ``fetch()`` has not been called on the manager yet.
71+
6872
#### `extend`
6973

7074
```python
@@ -99,6 +103,10 @@ add(self, data: str | RelatedNodeSync | dict) -> None
99103

100104
Add a new peer to this relationship.
101105

106+
**Raises:**
107+
108+
- `UninitializedError`: If ``fetch()`` has not been called on the manager yet.
109+
102110
#### `extend`
103111

104112
```python

docs/docs_generation/content_gen_methods/mdx/mdx_collapsed_overload_section.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def from_overloads(cls, sections: list[MdxSection]) -> CollapsedOverloadSection:
4848
4949
Selects the overload with the most parameters as *primary*.
5050
On ties, the first in source order wins.
51+
52+
Raises:
53+
ValueError: If ``sections`` is empty.
54+
5155
"""
5256
if not sections:
5357
raise ValueError("Cannot create CollapsedOverloadSection from an empty list")

infrahub_sdk/_importer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ def import_module(module_path: Path, import_root: str | None = None, relative_pa
2121
import_root (Optional[str]): Absolute string path to the current repository.
2222
relative_path (Optional[str]): Relative string path between module_path and import_root.
2323
24+
Raises:
25+
ModuleImportError: If the module cannot be found or contains a syntax error.
26+
2427
"""
2528
import_root = import_root or str(module_path.parent)
2629

0 commit comments

Comments
 (0)