Skip to content

Commit

Permalink
Improve docs regarding interpolations in structured config. Fixes #488 (
Browse files Browse the repository at this point in the history
#493)

* Improve docs regarding interpolations in structured config.  Fixes #488.

* Reword description of type validation in structured config
  • Loading branch information
SimonStJG authored Jan 30, 2021
1 parent e4d34f8 commit cf4b259
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions docs/source/structured_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ in the input class.

Simple types
^^^^^^^^^^^^
Simple types includes
Simple types include
- int : numeric integers
- float : numeric floating point values
- bool : boolean values (True, False, On, Off etc)
Expand All @@ -53,7 +53,7 @@ The following class defines fields with all simple types:
... description: str = "text"

You can create a config based on the SimpleTypes class itself or instances of it.
Those would be equivalent by default, but the Object variant allow you to set the values of specific
Those would be equivalent by default, but the Object variant allows you to set the values of specific
fields during construction.

.. doctest::
Expand Down Expand Up @@ -333,6 +333,19 @@ To work around it, use SI and II described below.
>>> assert conf.c == 100


Type validation is performed on assignment, but not on values returned by interpolation, e.g:

.. doctest::

>>> from omegaconf import SI
>>> @dataclass
... class Interpolation:
... int_key: int = II("str_key")
... str_key: str = "string"

>>> cfg = OmegaConf.structured(Interpolation)
>>> assert cfg.int_key == "string"

Frozen
^^^^^^

Expand Down

0 comments on commit cf4b259

Please sign in to comment.