ConfigValue#

class ConfigValue(input, key, origin=None)#

Bases: object

Value obtained from a source.

It stores a number of information about the value (its origin, initial value, etc.).

Parameters:
  • input (Any) – The initial value obtained from a configuration source.

  • key (str) – The key it was associated with in the source. For information purpose mainly.

  • origin (str | None) – A string specifying the configuration source it was found in. For information purpose mainly.

container_cls: type[HasTraits] | None#

The configurable class that owns the trait.

copy()#

Return a copy of this instance.

Return type:

Self

get_value()#

Return the actual value to use as parameter.

By default, use the value attribute, unless it is Undefined then use the initial value (possibly unparsed).

Return type:

Any

input#

The initial value obtained.

key#

The key this value was associated to.

origin#

A description of the configuration source it was found in.

parse()#

Parse the initial value.

Parsing traits is done by either TraitType.from_string or Container.from_string_list for container traits.

We have to choose the correct function, and traitlets.Union traits does not do that (if no correct parsing is found it just return the input string, and if a correct value is extracted the trait tries to validate it and may fail and raise).

This method tries to handle containers and union more gracefully. If all options have been tried and no parsing was successful the function will raise.

Return type:

None

property path: list[str]#

List of the dot-separated names of the key.

trait: TraitType | None#

The trait instance specifying the parameter to configure.

value: Any#

The parameter value once parsed.

By default, it equals to Undefined.