{"id":34107246,"url":"https://github.com/felixscode/heracless","last_synced_at":"2026-04-01T23:34:39.250Z","repository":{"id":174257665,"uuid":"601342686","full_name":"felixscode/heracless","owner":"felixscode","description":"Type-safe YAML config manager for Python with auto-generated stub files and IDE autocompletion support","archived":false,"fork":false,"pushed_at":"2025-11-15T16:38:17.000Z","size":847,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-02T17:50:46.705Z","etag":null,"topics":["autocompletion","automation","config","config-management","config-manager","configs","configuration","hydra","python","python3","stub-file","tyesafety","yaml-parser"],"latest_commit_sha":null,"homepage":"https://heracless.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/felixscode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-02-13T21:36:05.000Z","updated_at":"2025-12-11T12:42:26.000Z","dependencies_parsed_at":"2024-12-04T21:22:48.305Z","dependency_job_id":"bc851cdd-ca44-454a-b21f-c6d0b265045f","html_url":"https://github.com/felixscode/heracless","commit_stats":null,"previous_names":["felixscode/heracless"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/felixscode/heracless","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixscode%2Fheracless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixscode%2Fheracless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixscode%2Fheracless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixscode%2Fheracless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felixscode","download_url":"https://codeload.github.com/felixscode/heracless/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixscode%2Fheracless/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autocompletion","automation","config","config-management","config-manager","configs","configuration","hydra","python","python3","stub-file","tyesafety","yaml-parser"],"created_at":"2025-12-14T18:05:20.082Z","updated_at":"2026-04-01T23:34:39.224Z","avatar_url":"https://github.com/felixscode.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# Heracless\n\n\n![Heracless](https://images.unsplash.com/photo-1728246950251-d0ca4d99e927?q=80\u0026w=800\u0026auto=format\u0026fit=crop\u0026ixlib=rb-4.1.0\u0026ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D)\n\n**Type-safe YAML configuration management for Python**\n\nTransform your YAML config files into strongly-typed Python dataclasses with full IDE autocomplete support\n\n[![PyPI version](https://badge.fury.io/py/heracless.svg)](https://badge.fury.io/py/heracless)\n[![Python Version](https://img.shields.io/pypi/pyversions/heracless)](https://pypi.org/project/heracless/)\n[![Rust](https://img.shields.io/badge/Rust-1.70+-orange?logo=rust)](https://www.rust-lang.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Tests](https://github.com/felixscode/heracless/actions/workflows/test.yml/badge.svg)](https://github.com/felixscode/heracless/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/felixscode/heracless/branch/main/graph/badge.svg)](https://codecov.io/gh/felixscode/heracless)\n[![mypy](https://img.shields.io/badge/mypy-checked-blue)](http://mypy-lang.org/)\n[![Documentation](https://img.shields.io/badge/docs-mkdocs-blue)](https://heracless.io)\n\n[Installation](#installation) • [Quick Start](#quick-start) • [Documentation](https://heracless.io) • [Examples](#usage-examples)\n\n\u003c/div\u003e\n\n---\n\n## Why Heracless?\n\nStop wrestling with dictionaries and string keys. Heracless automatically converts your YAML configuration files into Python dataclasses with **full type safety** and **IDE autocomplete support**.\nPlus it's written in Rust for blazing-fast performance.\n\n```python\n# WITHOUT Heracless - prone to typos, no autocomplete\nconfig = yaml.load(open(\"config.yaml\"))\ndb_host = config[\"database\"][\"host\"]  # Runtime errors waiting to happen\ndb_port = config[\"databse\"][\"port\"]   # Typo goes unnoticed!\n\n# WITH Heracless - type-safe, autocomplete, catch errors at write-time\nconfig = load_config()\ndb_host = config.database.host  # Autocomplete works!\ndb_port = config.database.port  # Typos caught by IDE/mypy\n```\n\n---\n\n## Features\n\n- **Automatic Type Generation** - Generates `.pyi` stub files for full IDE support\n- **Type Safety** - Catch configuration errors at development time, not runtime\n- **Zero Boilerplate** - No manual dataclass definitions needed\n- **IDE Autocomplete** - Full IntelliSense/autocomplete for all config values\n- **Immutable by Default** - Frozen dataclasses prevent accidental modifications\n- **Rust-Powered Performance** - Native Rust backend for blazing-fast YAML parsing and stub generation\n\n---\n\n## Installation\n\n### From PyPI (Recommended)\n\n```bash\npip install heracless\n```\n\n### From Source\n\n```bash\ngit clone https://github.com/felixscode/heracless.git\ncd heracless\npip install -e .\n```\n\n### Requirements\n\n| Python Version | Status |\n|---------------|--------|\n| 3.10 - 3.13 | Fully Supported |\n| 3.9 and below | Not Supported |\n\n**Dependencies:** PyYAML, black, art\n\n**Note:** Prebuilt Rust wheels are available for Linux, macOS, and Windows. No Rust installation required!\n\n---\n\n## Quick Start\n\n### 1. Create your configuration file\n\nCreate a `config.yaml` file with your settings:\n\n```yaml\n# config.yaml\ndatabase:\n  host: localhost\n  port: 5432\n  name: myapp_db\n  credentials:\n    username: admin\n    password: secret123 # don't use this in production\n\napi:\n  base_url: https://api.example.com\n  timeout: 30\n  retries: 3\n\nfeatures:\n  enable_caching: true\n  max_cache_size: 1000\n```\n\n### 2. Set up the config loader\n\nCreate a `load_config.py` file in your project:\n\n```python\n# src/myproject/load_config.py\nfrom pathlib import Path\nfrom typing import TypeVar\nfrom heracless import load_config as _load_config\n\n# Point to your config file\nCONFIG_YAML_PATH = Path(__file__).parent.parent / \"config.yaml\"\n\nConfig = TypeVar(\"Config\")\n\ndef load_config(config_path: Path | str = CONFIG_YAML_PATH,\n                frozen: bool = True,\n                stub_dump: bool = True) -\u003e Config:\n    \"\"\"Load configuration and generate type stubs.\"\"\"\n    file_path = Path(__file__).resolve() if stub_dump else None\n    return _load_config(config_path, file_path, frozen=frozen)\n```\n\n### 3. Use your config with full type safety\n\n```python\n# src/myproject/main.py\nfrom myproject.load_config import load_config\n\n# Load config - first run generates load_config.pyi with types!\nconfig = load_config()\n\n# Access config with autocomplete and type checking\nprint(f\"Connecting to {config.database.host}:{config.database.port}\")\nprint(f\"Database: {config.database.name}\")\nprint(f\"API URL: {config.api.base_url}\")\nprint(f\"Caching enabled: {config.features.enable_caching}\")\n```\n\n**Output:**\n```\nConnecting to localhost:5432\nDatabase: myapp_db\nAPI URL: https://api.example.com\nCaching enabled: True\n```\n\n### Generated Type Stub Example\n\nAfter the first run, Heracless automatically generates a `load_config.pyi` file:\n\n```python\n# load_config.pyi (auto-generated)\nfrom dataclasses import dataclass\nfrom typing import TypeVar\n\n@dataclass(frozen=True)\nclass Credentials:\n    username: str\n    password: str\n\n@dataclass(frozen=True)\nclass Database:\n    host: str\n    port: int\n    name: str\n    credentials: Credentials\n\n@dataclass(frozen=True)\nclass Api:\n    base_url: str\n    timeout: int\n    retries: int\n\n@dataclass(frozen=True)\nclass Features:\n    enable_caching: bool\n    max_cache_size: int\n\n@dataclass(frozen=True)\nclass Config:\n    database: Database\n    api: Api\n    features: Features\n\n```\n\nThis stub file enables **full IDE autocomplete and type checking**\n\n\n---\n\n## Usage Examples\n\n### Basic Configuration Loading\n\n```python\nfrom myproject.load_config import load_config\n\n# Load with defaults (frozen, with stub generation)\nconfig = load_config()\n\n# Access nested values with autocomplete\ndb_url = f\"{config.database.host}:{config.database.port}\"\n```\n\n### Mutable Configuration\n\n```python\n# Load mutable config for testing or dynamic updates\nconfig = load_config(frozen=False)\n\n# Modify values (only works with frozen=False)\nconfig.database.host = \"192.168.1.100\"\n```\n\n### Converting to Dictionary\n\n```python\nfrom heracless.utils.helper import as_dict\n\nconfig = load_config()\nconfig_dict = as_dict(config)\n\n# Now a regular Python dictionary\nprint(config_dict[\"database\"][\"host\"])  # localhost\n```\n\n### Creating Config from Dictionary\n\n```python\nfrom heracless.utils.helper import from_dict\n\nconfig_dict = {\n    \"database\": {\n        \"host\": \"localhost\",\n        \"port\": 5432\n    },\n    \"api\": {\n        \"base_url\": \"https://api.example.com\",\n        \"timeout\": 30\n    }\n}\n\nconfig = from_dict(config_dict, frozen=True)\nprint(config.database.host)  # localhost (with type checking!)\n```\n\n### Updating Configuration Values\n\n```python\nfrom heracless.utils.helper import mutate_config\n\nconfig = load_config()\n\n# Create a new config with updated value (immutable pattern)\nnew_config = mutate_config(config, \"database.host\", \"production-db.example.com\")\n\nprint(config.database.host)      # localhost (original unchanged)\nprint(new_config.database.host)  # production-db.example.com\n```\n\n### CLI Tool Usage\n\nHeracless includes a CLI tool for generating stub files and validating configs:\n\n```bash\n# Generate stub file from config\npython -m heracless config.yaml --parse types.pyi\n\n# Dry run (validate config without generating files)\npython -m heracless config.yaml --dry\n\n# Show help\npython -m heracless --help\n```\n\n---\n\n## Project Structure Example\n\nHere's a recommended project structure:\n\n```\nmy_project/\n├── src/\n│   └── myproject/\n│       ├── __init__.py\n│       ├── main.py\n│       └── config/\n│           ├── __init__.py\n│           ├── load_config.py      # Your config loader\n│           └── load_config.pyi     # Auto-generated types\n├── config/\n│   ├── config.yaml                 # Main config\n│   ├── config.dev.yaml             # Development overrides\n│   └── config.prod.yaml            # Production overrides\n├── tests/\n│   └── test_config.py\n├── pyproject.toml\n└── README.md\n```\n\n---\n\n## Troubleshooting\n\n\n\n\n### **Issue: IDE not showing autocomplete**\n\n**Solutions:**\n1. Ensure the `.pyi` file exists next to your `load_config.py`\n2. Reload your IDE/editor window\n3. Check that your language server is running (VSCode: check Python extension)\n4. For PyCharm: File → Invalidate Caches → Restart\n\n#### **Issue: `TypeError: 'Config' object is immutable`**\n\n**Solution:** This is by design (frozen dataclass). To modify configs:\n- Use `mutate_config()` helper to create updated copies\n- Or load with `frozen=False` for mutable configs (not recommended)\n\n#### **Issue: YAML parsing errors**\n\n**Solution:** Ensure your YAML is valid:\n```bash\n# Validate YAML syntax\npython -c \"import yaml; yaml.safe_load(open('config.yaml'))\"\n```\n\n---\n\n## API Reference\n\n### Core Functions\n\n#### `load_config(config_path, file_path, frozen)`\n\nLoad a YAML configuration file and convert it to a typed dataclass.\n\n**Parameters:**\n- `config_path` (Path | str): Path to the YAML configuration file\n- `file_path` (Path | str | None): Path where stub file should be generated (None to skip)\n- `frozen` (bool): Whether the resulting dataclass should be immutable (default: True)\n\n**Returns:** Config dataclass with attributes matching your YAML structure\n\n**Raises:**\n- `FileNotFoundError`: If config file doesn't exist\n- `yaml.YAMLError`: If YAML file is malformed\n\n---\n\n### Helper Functions\n\n#### `mutate_config(config, name, value)`\n\nCreate a new config with an updated value (immutable pattern).\n\n```python\nfrom heracless.utils.helper import mutate_config\n\nconfig = load_config()\nnew_config = mutate_config(config, \"database.port\", 3306)\n```\n\n#### `as_dict(config)`\n\nConvert a Config dataclass to a nested dictionary.\n\n```python\nfrom heracless.utils.helper import as_dict\n\nconfig = load_config()\nconfig_dict = as_dict(config)  # Returns: dict\n```\n\n#### `from_dict(config_dict, frozen)`\n\nCreate a Config dataclass from a dictionary.\n\n```python\nfrom heracless.utils.helper import from_dict\n\nconfig_dict = {\"database\": {\"host\": \"localhost\"}}\nconfig = from_dict(config_dict, frozen=True)\n```\n\n---\n\n## Contributing\n\nContributions are welcome! Here's how you can help:\n\n### Development Setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/felixscode/heracless.git\ncd heracless\n\n# Install with development dependencies\npip install -e .[dev]\n\n# Run tests\npytest\n\n# Run type checking\nmypy heracless\n\n# Run code formatting\nblack heracless tests\n```\n\n### Running Tests\n\n```bash\n# Run all tests\npytest\n\n# Run with coverage\npytest --cov=heracless --cov-report=html\n\n# Run specific test file\npytest tests/test_config.py\n```\n\n### Development Dependencies\n\nInstall development dependencies with:\n\n```bash\npip install -e .[dev]\n```\n\nThis includes:\n- `pytest` - Testing framework\n- `pytest-cov` - Coverage reporting\n- `mypy` - Static type checking\n- `types-PyYAML` - Type stubs for PyYAML\n\n### Documentation Development\n\nTo work on the documentation:\n\n```bash\n# Install documentation dependencies\npip install -e .[doc]\n\n# Serve documentation locally\nmkdocs serve\n\n# Build documentation\nmkdocs build\n```\n\n\n### Reporting Issues\n\nFound a bug or have a feature request? [Open an issue](https://github.com/felixscode/heracless/issues) on GitHub.\n\nPlease include:\n- Heracless version (`pip show heracless`)\n- Python version\n- Operating system\n- Minimal reproducible example\n- Expected vs actual behavior\n\n---\n\n## Roadmap\n\n### Current Version: 0.5.1\n\n### Planned Features\n\n- [ ] **Config variants** - Support for environment-specific configs (dev/staging/prod)\n- [ ] **Environment variable interpolation** - `${ENV_VAR}` syntax in YAML\n\n---\n\n## License\n\nHeracless is released under the **MIT License**. See [LICENSE](LICENSE) file for details.\n\n```\nMIT License\n\nCopyright (c) 2023 Felix Schelling\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n```\n\n**TL;DR:** You can freely use, modify, and distribute this software, even for commercial purposes.\n\n---\n\n## Links \u0026 Resources\n\n- **PyPI Package:** [pypi.org/project/heracless](https://pypi.org/project/heracless/)\n- **Documentation:** [heracless.io](https://heracless.io)\n- **GitHub Repository:** [github.com/felixscode/heracless](https://github.com/felixscode/heracless)\n- **Issues \u0026 Support:** [GitHub Issues](https://github.com/felixscode/heracless/issues)\n\n---\n\n## Author\n\n**Felix Schelling**\n\n- GitHub: [@felixscode](https://github.com/felixscode)\n- Website: [felixschelling.de](https://felixschelling.de)\n\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**If Heracless helps your project, consider giving it a star on GitHub!**\n\n[Back to Top](#heracless)\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixscode%2Fheracless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelixscode%2Fheracless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixscode%2Fheracless/lists"}