pconfig¶

pconfigs.pconfig(_first=None, *, constructs=None, calls=None, mocks=None, inherit_constructable_type=None)[source]¶

Decorator that creates a pconfig class.

See also

For examples, see Construction.

Usage patterns:

  • @pconfig or @pconfig(): Creates a plain pconfig dataclass.

  • @pconfig(constructs=MyClass): Creates a pconfig that constructs a corresponding @pconfiged class of type MyClass.

  • @pconfig(calls=my_function): Creates a pconfig that calls a function that uses simply typed optional keyword arguments to define its configuration.

  • @pconfig(mocks=ExternalClass): Creates a pconfig that constructs an external class that uses simply typed optional keyword arguments to define its configuration. Do not use this pattern to design your own classes—future versions of pconfigs may raise an error if you do.

Parameters:
  • constructs (type, optional) – A class that the pconfig should construct.

  • calls (Callable, optional) – A function that the pconfig should call.

  • mocks (type, optional) – An external class that the pconfig should construct using simply-typed keyword arguments.

  • inherit_constructable_type (bool, optional) – If True, the pconfig will inherit the constructable type of constructs, calls, or mocks.

Note

Exactly one of constructs, calls, or mocks should be provided. Supplying more than one is an error.

Raises:

ValueError – If more than one of constructs, calls, or mocks is provided.