Skip to content

Consolidate config access patterns #57

@aquarion

Description

@aquarion

Config access is inconsistent across the codebase. Some files use try/except, others access directly.

Current patterns seen

  • Direct access: lifestream.config.get('section', 'key')
  • Try/except with default: try: val = config.get(...) except: val = None
  • Has_option check: if config.has_option('section', 'key'): ...

Proposed solution

Add helper functions to lifestream/__init__.py:

def get_config(section: str, key: str, default: str | None = None) -> str | None:
    """Get config value with optional default."""
    if config.has_option(section, key):
        return config.get(section, key)
    return default

def get_config_bool(section: str, key: str, default: bool = False) -> bool:
    """Get boolean config value."""
    if config.has_option(section, key):
        return config.getboolean(section, key)
    return default

Benefits

  • Consistent error handling
  • Cleaner code in import scripts
  • Type-safe accessors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions