UserOptionConfigured

giant.utilities.mixin_classes.user_option_configured:

class giant.utilities.mixin_classes.user_option_configured.UserOptionConfigured(options_type, *args, options=None, **kwargs)[source]

Mixin class providing UserOptions-based configuration with reset capability.

This mixin class enables classes to be configured using UserOptions-derived classes and provides the ability to reset the class to its default (initially provided) state.

The class works in conjunction with the UserOptions ABC to provide:

  • Automatic configuration of class instances based on provided options

  • Storage of original configuration for reset functionality

  • Type-safe option handling through generic typing

To use this mixin, subclass it with the UserOptions subclass as the type parameter:

class MyUsefulClass(UserOptionConfigured[MyOptions], MyOptions):
    def __init__(self, options: MyOptions = None):
        super().__init__(MyOptions, options)
Parameters:
  • OptionsT – The UserOptions-derived class type for configuration

  • options_type (type[OptionsT])

  • options (OptionsT | None)

Attr original_options:

The original configuration used during initialization. This is stored as a deep copy and used for reset operations.

Warning

If options are not provided during initialization, default initialization of the options_type class will be used.

Parameters:
  • options_type (type[OptionsT]) – The type of the UserOptions to use

  • options (OptionsT | None) – An optional oinstance of options_type preconfigured.

reset_settings()[source]

Resets the class to the state it was originally initialized with.

Return type:

None

property original_options: OptionsT

Get the original configuration options.

Returns:

OptionsT: The original options used during initialization.

Warning

Modifying the returned object will affect reset behavior.