spyder.api.config.decorators

spyder.api.config.decorators#

Spyder API helper decorators.

Module Attributes

ConfigurationKeyList

Type alias for a list of string/string tuple keys of Spyder config options.

ConfigurationKeyOrList

Type alias for either a list of config keys or a single key.

Functions

on_conf_change([func, section, option])

Decorator to handle changing a config option in a given section.

spyder.api.config.decorators.ConfigurationKeyList#

Type alias for a list of string/string tuple keys of Spyder config options.

A list of spyder.config.types.ConfigurationKeys.

alias of list[str | Tuple[str, …]]

spyder.api.config.decorators.ConfigurationKeyOrList#

Type alias for either a list of config keys or a single key.

Union of types ConfigurationKeyList and spyder.config.types.ConfigurationKey.

alias of list[str | Tuple[str, …]] | str | Tuple[str, …]

spyder.api.config.decorators.on_conf_change(func: Callable | None = None, section: str | None = None, option: ConfigurationKeyOrList | None = None) Callable[source]#

Decorator to handle changing a config option in a given section.

The methods that use this decorator must have the signature

def method(self, value: Any):
    ...

when observing a single value or the whole section, and

def method(self, option: ConfigurationKeyOrList | None, value: Any):
    ...

when observing multiple values.

Parameters:
  • func (Callable | None, optional) – Method to decorate, passed automatically when applying the decorator.

  • section (str | None, optional) – Name of the configuration section to observe for changes. If None, then the CONF_SECTION attribute of the class where the method defined is used.

  • option (ConfigurationKeyOrList | None, optional) – Name (str / tuple of str) of the option to observe, or a list of names if the method expects updates from multiple keys. If None, then all changes to options in the specified section are observed.

Returns:

func – The method passed as func with the config listener set up.

Return type:

Callable