From 356684e5d4a54529043dec1c11b354ffac068d79 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 9 Jan 2026 09:39:19 +0000 Subject: [PATCH] rename Settings to Config --- obsws_cli/app.py | 16 +++++------ obsws_cli/{settings.py => config.py} | 42 ++++++++++++++-------------- 2 files changed, 29 insertions(+), 29 deletions(-) rename obsws_cli/{settings.py => config.py} (54%) diff --git a/obsws_cli/app.py b/obsws_cli/app.py index e83c010..531ea7b 100644 --- a/obsws_cli/app.py +++ b/obsws_cli/app.py @@ -9,7 +9,7 @@ import typer from obsws_cli.__about__ import __version__ as version -from . import console, settings, styles +from . import config, console, styles from .alias import RootTyperAliasGroup app = typer.Typer(cls=RootTyperAliasGroup) @@ -72,7 +72,7 @@ def main( help='WebSocket host', show_default='localhost', ), - ] = settings.get('host'), + ] = config.get('host'), port: Annotated[ int, typer.Option( @@ -82,7 +82,7 @@ def main( help='WebSocket port', show_default=4455, ), - ] = settings.get('port'), + ] = config.get('port'), password: Annotated[ str, typer.Option( @@ -92,7 +92,7 @@ def main( help='WebSocket password', show_default=False, ), - ] = settings.get('password'), + ] = config.get('password'), timeout: Annotated[ int, typer.Option( @@ -102,7 +102,7 @@ def main( help='WebSocket timeout', show_default=5, ), - ] = settings.get('timeout'), + ] = config.get('timeout'), style: Annotated[ str, typer.Option( @@ -113,7 +113,7 @@ def main( show_default='disabled', callback=validate_style, ), - ] = settings.get('style'), + ] = config.get('style'), no_border: Annotated[ bool, typer.Option( @@ -123,7 +123,7 @@ def main( help='Disable table border styling in the CLI output', show_default=False, ), - ] = settings.get('style_no_border'), + ] = config.get('style_no_border'), version: Annotated[ bool, typer.Option( @@ -147,7 +147,7 @@ def main( callback=setup_logging, hidden=True, ), - ] = settings.get('debug'), + ] = config.get('debug'), ): """obsws_cli is a command line interface for the OBS WebSocket API.""" ctx.ensure_object(dict) diff --git a/obsws_cli/settings.py b/obsws_cli/config.py similarity index 54% rename from obsws_cli/settings.py rename to obsws_cli/config.py index e2085bc..7973b48 100644 --- a/obsws_cli/settings.py +++ b/obsws_cli/config.py @@ -5,21 +5,21 @@ from pathlib import Path from dotenv import dotenv_values -SettingsValue = str | int +ConfigValue = str | int -class Settings(UserDict): - """A class to manage settings for obsws-cli. +class Config(UserDict): + """A class to manage config for obsws-cli. - This class extends UserDict to provide a dictionary-like interface for settings. - It loads settings from environment variables and .env files. - The settings are expected to be in uppercase and should start with 'OBS_'. + This class extends UserDict to provide a dictionary-like interface for config. + It loads config from environment variables and .env files. + The config values are expected to be in uppercase and should start with 'OBS_'. Example: ------- - settings = Settings() - host = settings['OBS_HOST'] - settings['OBS_PORT'] = 4455 + config = Config() + host = config['OBS_HOST'] + config['OBS_PORT'] = 4455 """ @@ -35,22 +35,22 @@ class Settings(UserDict): ) super().__init__(*args, **kwargs) - def __getitem__(self, key: str) -> SettingsValue: + def __getitem__(self, key: str) -> ConfigValue: """Get a setting value by key.""" key = key.upper() - if not key.startswith(Settings.PREFIX): - key = f'{Settings.PREFIX}{key}' + if not key.startswith(Config.PREFIX): + key = f'{Config.PREFIX}{key}' return self.data[key] - def __setitem__(self, key: str, value: SettingsValue): + def __setitem__(self, key: str, value: ConfigValue): """Set a setting value by key.""" key = key.upper() - if not key.startswith(Settings.PREFIX): - key = f'{Settings.PREFIX}{key}' + if not key.startswith(Config.PREFIX): + key = f'{Config.PREFIX}{key}' self.data[key] = value -_settings = Settings( +_config = Config( OBS_HOST='localhost', OBS_PORT=4455, OBS_PASSWORD='', @@ -61,20 +61,20 @@ _settings = Settings( ) -def get(key: str) -> SettingsValue: +def get(key: str) -> ConfigValue: """Get a setting value by key. Args: ---- - key (str): The key of the setting to retrieve. + key (str): The key of the config to retrieve. Returns: ------- - The value of the setting. + The value of the config. Raises: ------ - KeyError: If the key does not exist in the settings. + KeyError: If the key does not exist in the config. """ - return _settings[key] + return _config[key]