config.py: remove class members that should be instance members from ConfigStateHolder

This commit is contained in:
InsanePrawn 2022-08-15 05:26:28 +02:00
parent 0d4d83f0ed
commit de71a71c13

View file

@ -265,23 +265,23 @@ class ConfigLoadException(Exception):
super().__init__(self, ' '.join(msg)) super().__init__(self, ' '.join(msg))
class ConfigStateHolder:
class ConfigLoadState: class ConfigLoadState:
load_finished = False load_finished = False
exception = None exception = None
file_state = ConfigLoadState()
defaults = CONFIG_DEFAULTS class ConfigStateHolder:
# config options that are persisted to file # config options that are persisted to file
file: dict = {} file: dict = {}
# runtime config not persisted anywhere # runtime config not persisted anywhere
runtime: dict = CONFIG_RUNTIME_DEFAULTS runtime: dict
file_state: ConfigLoadState
_profile_cache: dict[str, Profile] _profile_cache: dict[str, Profile]
def __init__(self, runtime_conf={}, file_conf_path: Optional[str] = None, file_conf_base: dict = {}): def __init__(self, runtime_conf={}, file_conf_path: Optional[str] = None, file_conf_base: dict = {}):
"""init a stateholder, optionally loading `file_conf_path`""" """init a stateholder, optionally loading `file_conf_path`"""
self.file_state = ConfigLoadState()
self.runtime = CONFIG_RUNTIME_DEFAULTS.copy()
self.runtime.update(runtime_conf) self.runtime.update(runtime_conf)
self.runtime['arch'] = os.uname().machine self.runtime['arch'] = os.uname().machine
self.file.update(file_conf_base) self.file.update(file_conf_base)
@ -478,7 +478,7 @@ def prompt_for_save(retry_ctx: Optional[click.Context] = None):
return False return False
config = ConfigStateHolder(file_conf_base=CONFIG_DEFAULTS) config: ConfigStateHolder = ConfigStateHolder(file_conf_base=CONFIG_DEFAULTS)
config_option = click.option( config_option = click.option(
'-C', '-C',