Skip to content

Variables Substitution System

Choose a tag to compare

@ALERTua ALERTua released this 21 Feb 15:45
· 85 commits to main since this release

Overview

Introduces a variable substitution system for the configuration, along with project infrastructure improvements and bug fixes.


✨ Feature: Config Variable Substitution

The configuration system now supports flexible variable substitution, making configs more reusable and maintainable.

Supported Syntax

  1. Environment Variables - %ENV_VAR%

    • Use OS environment variables in any path or value
    • Expanded at config load time
    variables:
      user_home: '%USERPROFILE%'
    entries:
      my_entry:
        target: '%USER_HOME%\Downloads\file.exe'
  2. Config Variables - {{variable_name}}

    • Define custom variables in the variables: section
    • Reference them anywhere in entries
    variables:
      games_dir: 'D:\Games'
      gw2_dir: '{{games_dir}}\GW2'
    entries:
      my_entry:
        target: '{{gw2_dir}}\bin64'
  3. Chained Variable References

    • Variables can reference other variables defined earlier
    • Processed in order, enabling powerful composition
    variables:
      base_dir: 'D:\Games'
      gw2_dir: '{{base_dir}}\GW2'        # References base_dir
      tools_dir: '{{gw2_dir}}\tools'      # References gw2_dir
  4. Per-Entry Variables

    • Each entry can define its own variables
    • Entry-specific variables override global ones
    variables:
      drive_root: 'D:\'          # Global default
    entries:
      my_entry:
        variables:
          drive_root: 'C:\'     # Override for this entry only
        target: '{{drive_root}}\file.exe'

🔧 Infrastructure Improvements

  • Project Structure: Migrated to src layout for better packaging
  • Pre-commit Hooks: Added comprehensive pre-commit configuration with:
    • Code quality checks (ruff)
    • Formatting (ruff-format)
    • YAML validation
    • TODO tracking
  • Development Tools: Added pytest-asyncio, ruff, rust-just

🐛 Bug Fixes

  • Fixed: Infinite recursion in config validation
    • Previously, accessing config.entries triggered Dynaconf setup
    • Now reads YAML directly to avoid validation loops

New Dependencies

  • pytest-asyncio
  • ruff
  • pre-commit
  • pre-commit-uv
  • rust-just

Migration Guide

Updating Existing Configs

If you have existing configs, they will continue to work. However, you can now leverage the new variable system:

Before:

entries:
  d912pxy:
    target: 'D:\Games\GW2\_tools\d912pxy.zip'
    unzip_target: 'D:\Games\GW2'

After (with variables):

variables:
  games_dir: 'D:\Games'
  gw2_dir: '{{games_dir}}\GW2'
  tools_dir: '{{gw2_dir}}\_tools'

entries:
  d912pxy:
    target: '{{tools_dir}}\d912pxy.zip'
    unzip_target: '{{gw2_dir}}'

Breaking Changes

  • Python 3.14 Required: The project now requires Python 3.14
  • Removed: .python-version file (use pyproject.toml instead)