|
29 | 29 |
|
30 | 30 | from __future__ import annotations |
31 | 31 |
|
32 | | -import warnings |
33 | 32 | from collections.abc import Iterable |
34 | 33 | from pathlib import Path |
35 | 34 | from typing import Any |
@@ -62,7 +61,7 @@ class ConfigNode: |
62 | 61 |
|
63 | 62 | A :class:`ConfigNode` may only have a value set at each layer once. |
64 | 63 | Attempts to set a value at the same layer multiple times will result in |
65 | | - a :class:`DuplicatedConfigurationError`. |
| 64 | + a :class:`~layered_config_tree.exceptions.DuplicatedConfigurationError`. |
66 | 65 |
|
67 | 66 | The :class:`ConfigNode` will record all values set and the source they |
68 | 67 | are set from. This sort of provenance with configuration data greatly |
@@ -110,7 +109,6 @@ def freeze(self) -> None: |
110 | 109 |
|
111 | 110 | This can be used to create a contract around when the configuration is |
112 | 111 | modifiable. |
113 | | -
|
114 | 112 | """ |
115 | 113 | self._frozen = True |
116 | 114 |
|
@@ -158,7 +156,6 @@ def update(self, value: Any, layer: str | None, source: str | None) -> None: |
158 | 156 | DuplicatedConfigurationError |
159 | 157 | If a value has already been set at the provided layer or a value |
160 | 158 | is already in the outermost layer and no layer has been provided. |
161 | | -
|
162 | 159 | """ |
163 | 160 | if self._frozen: |
164 | 161 | raise ConfigurationError( |
@@ -193,8 +190,8 @@ def _get_value_with_source(self, layer: str | None) -> tuple[str | None, Any]: |
193 | 190 |
|
194 | 191 | Returns |
195 | 192 | ------- |
196 | | - The (source, value) tuple at the specified layer or, if no layer is |
197 | | - specified, at the outermost (highest priority) layer. |
| 193 | + The (source, value) tuple at the specified layer or, if no layer is |
| 194 | + specified, at the outermost (highest priority) layer. |
198 | 195 |
|
199 | 196 | Raises |
200 | 197 | ------ |
@@ -247,6 +244,7 @@ class ConfigIterator: |
247 | 244 | An iterator for a LayeredConfigTree object. |
248 | 245 |
|
249 | 246 | This iterator is used to iterate over the keys of a LayeredConfigTree object. |
| 247 | +
|
250 | 248 | """ |
251 | 249 |
|
252 | 250 | def __init__(self, config_tree: LayeredConfigTree): |
@@ -319,7 +317,6 @@ def freeze(self) -> None: |
319 | 317 |
|
320 | 318 | This is useful for loading and then freezing configurations that |
321 | 319 | should not be modified at runtime. |
322 | | -
|
323 | 320 | """ |
324 | 321 | self.__dict__["_frozen"] = True |
325 | 322 | for child in self.values(): |
@@ -353,7 +350,6 @@ def to_dict(self) -> dict[str, Any]: |
353 | 350 | """Converts the LayeredConfigTree into a nested dictionary. |
354 | 351 |
|
355 | 352 | All metadata is lost in this conversion. |
356 | | -
|
357 | 353 | """ |
358 | 354 | result = {} |
359 | 355 | for name, child in self.items(): |
@@ -386,9 +382,9 @@ def get( |
386 | 382 |
|
387 | 383 | Returns |
388 | 384 | ------- |
389 | | - The value at the key or nested keys and at the requested layer (the outer, by default). |
390 | | - ``default_value`` (None, by default) is returned if the full key path *except |
391 | | - for the final key* exists at an *explicitly-requested* layer. |
| 385 | + The value at the key or nested keys and at the requested layer (the outer, by default). |
| 386 | + ``default_value`` (None, by default) is returned if the full key path *except |
| 387 | + for the final key* exists at an *explicitly-requested* layer. |
392 | 388 |
|
393 | 389 | Raises |
394 | 390 | ------ |
@@ -421,8 +417,8 @@ def get_tree(self, keys: str | list[str]) -> LayeredConfigTree: |
421 | 417 |
|
422 | 418 | Returns |
423 | 419 | ------- |
424 | | - The ``LayeredConfigTree`` located at the key or key path provided starting |
425 | | - from the outermost layer. |
| 420 | + The ``LayeredConfigTree`` located at the key or key path provided starting |
| 421 | + from the outermost layer. |
426 | 422 |
|
427 | 423 | Raises |
428 | 424 | ------ |
@@ -495,7 +491,6 @@ def update( |
495 | 491 | DuplicatedConfigurationError |
496 | 492 | If a value has already been set at the provided layer or a value |
497 | 493 | is already in the outermost layer and no layer has been provided. |
498 | | -
|
499 | 494 | """ |
500 | 495 | if data is not None: |
501 | 496 | data_dict, source = self._coerce(data, source) |
@@ -560,7 +555,6 @@ def _set_with_metadata( |
560 | 555 | DuplicatedConfigurationError |
561 | 556 | If a value has already been set at the provided layer or a value |
562 | 557 | is already in the outermost layer and no layer has been provided. |
563 | | -
|
564 | 558 | """ |
565 | 559 | if self._frozen: |
566 | 560 | raise ConfigurationError( |
|
0 commit comments