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:
@pconfigor@pconfig(): Creates a plain pconfig dataclass.@pconfig(constructs=MyClass): Creates a pconfig that constructs a corresponding@pconfigedclass of typeMyClass.@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, ormocks.
Note
Exactly one of
constructs,calls, ormocksshould be provided. Supplying more than one is an error.- Raises:
ValueError – If more than one of
constructs,calls, ormocksis provided.