Invoke's primary configuration handling class. See :doc:`/concepts/configuration` for details on the configuration system this class implements, including the :ref:`configuration hierarchy `. The rest of this class' documentation assumes familiarity with that
| 311 | |
| 312 | |
| 313 | class Config(DataProxy): |
| 314 | """ |
| 315 | Invoke's primary configuration handling class. |
| 316 | |
| 317 | See :doc:`/concepts/configuration` for details on the configuration system |
| 318 | this class implements, including the :ref:`configuration hierarchy |
| 319 | <config-hierarchy>`. The rest of this class' documentation assumes |
| 320 | familiarity with that document. |
| 321 | |
| 322 | **Access** |
| 323 | |
| 324 | Configuration values may be accessed and/or updated using dict syntax:: |
| 325 | |
| 326 | config['foo'] |
| 327 | |
| 328 | or attribute syntax:: |
| 329 | |
| 330 | config.foo |
| 331 | |
| 332 | Nesting works the same way - dict config values are turned into objects |
| 333 | which honor both the dictionary protocol and the attribute-access method:: |
| 334 | |
| 335 | config['foo']['bar'] |
| 336 | config.foo.bar |
| 337 | |
| 338 | **A note about attribute access and methods** |
| 339 | |
| 340 | This class implements the entire dictionary protocol: methods such as |
| 341 | ``keys``, ``values``, ``items``, ``pop`` and so forth should all function |
| 342 | as they do on regular dicts. It also implements new config-specific methods |
| 343 | such as `load_system`, `load_collection`, `merge`, `clone`, etc. |
| 344 | |
| 345 | .. warning:: |
| 346 | Accordingly, this means that if you have configuration options sharing |
| 347 | names with these methods, you **must** use dictionary syntax (e.g. |
| 348 | ``myconfig['keys']``) to access the configuration data. |
| 349 | |
| 350 | **Lifecycle** |
| 351 | |
| 352 | At initialization time, `.Config`: |
| 353 | |
| 354 | - creates per-level data structures; |
| 355 | - stores any levels supplied to `__init__`, such as defaults or overrides, |
| 356 | as well as the various config file paths/filename patterns; |
| 357 | - and loads config files, if found (though typically this just means system |
| 358 | and user-level files, as project and runtime files need more info before |
| 359 | they can be found and loaded.) |
| 360 | |
| 361 | - This step can be skipped by specifying ``lazy=True``. |
| 362 | |
| 363 | At this point, `.Config` is fully usable - and because it pre-emptively |
| 364 | loads some config files, those config files can affect anything that |
| 365 | comes after, like CLI parsing or loading of task collections. |
| 366 | |
| 367 | In the CLI use case, further processing is done after instantiation, using |
| 368 | the ``load_*`` methods such as `load_overrides`, `load_project`, etc: |
| 369 | |
| 370 | - the result of argument/option parsing is applied to the overrides level; |
no outgoing calls
no test coverage detected
searching dependent graphs…