{"id":19577144,"url":"https://github.com/illuin-tech/configue","last_synced_at":"2025-08-18T15:05:15.525Z","repository":{"id":39863924,"uuid":"240330941","full_name":"illuin-tech/configue","owner":"illuin-tech","description":"A YAML parser with advanced functionalities to ease your application configuration","archived":false,"fork":false,"pushed_at":"2025-08-12T11:23:11.000Z","size":320,"stargazers_count":36,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-12T12:41:26.974Z","etag":null,"topics":["configuration","environment-variables","python","yaml"],"latest_commit_sha":null,"homepage":null,"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/illuin-tech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","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}},"created_at":"2020-02-13T18:22:38.000Z","updated_at":"2025-08-12T11:23:14.000Z","dependencies_parsed_at":"2023-10-05T02:13:00.347Z","dependency_job_id":"2f69681c-94aa-4f00-bc5b-b181d8cb87b8","html_url":"https://github.com/illuin-tech/configue","commit_stats":{"total_commits":89,"total_committers":3,"mean_commits":"29.666666666666668","dds":0.4719101123595506,"last_synced_commit":"453f2b1ad1259c112e3f1594ad178e37fd82e015"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/illuin-tech/configue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illuin-tech%2Fconfigue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illuin-tech%2Fconfigue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illuin-tech%2Fconfigue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illuin-tech%2Fconfigue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/illuin-tech","download_url":"https://codeload.github.com/illuin-tech/configue/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illuin-tech%2Fconfigue/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271011804,"owners_count":24684413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["configuration","environment-variables","python","yaml"],"created_at":"2024-11-11T07:04:42.890Z","updated_at":"2025-08-18T15:05:15.501Z","avatar_url":"https://github.com/illuin-tech.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Configue\n========\n\n![CI](https://github.com/illuin-tech/configue/workflows/CI/badge.svg)\n[![codecov](https://codecov.io/gh/illuin-tech/configue/branch/master/graph/badge.svg)](https://codecov.io/gh/illuin-tech/configue)\n\nA YAML parser with advanced functionalities to ease your application configuration.\n\n# Who is this library for ?\nThis library is meant to be used in medium to large-scale applications, that have a lot of parameters to configure. \n\nModular applications especially can greatly benefit from using `configue` to easily inject new modules.\n\n# Installation\n\nRun `pip install configue` to install from PyPI.\n\nRun `pip install .` to install from sources.\n\nThis project follows the (Semantic Versioning Specification)[https://semver.org/].\nAll breaking changes are described in the [Changelog](CHANGELOG.md). \n\n# Usage\n\n### Basic usage\nThis library uses [PyYAML](https://github.com/yaml/pyyaml) to parse the YAML files and return the file content.\n\n```python\nimport configue\n\n\nconfig = configue.load(\"/path/to/yaml/file.yml\")\n```\n\n\n### Loading a sub path\nIf you are not interested in loading the whole file, you can only load a subpath:\n```yaml\n# config.yml\nsome_key:\n  some_list:\n    - first_item\n    - second_item:\n        item_key: item_value\n\nnot_loaded_key: not_loaded_value\n```\n\n```python\nimport configue\n\nconfig = configue.load(\"config.yml\", \"some_key.some_list.1.item_key\")\nassert config == \"item_value\"\n```\n\n### Instantiating classes\n\nUse `()` in your YAML files to instantiate classes:\n```yaml\n# config.yml\n(): \"my_project.MyAwesomeClass\"\nmy_argument: \"my_value\"\nmy_other_argument:\n  (): \"my_project.my_module.MyOtherClass\"\n```\n\n```python\nimport configue\nfrom my_project import MyAwesomeClass\nfrom my_project.my_module import MyOtherClass\n\n\nmy_instance = configue.load(\"config.yml\")\nassert isinstance(my_instance, MyAwesomeClass)\nassert my_instance.my_argument == \"my_value\"\nassert isinstance(my_instance.my_other_argument, MyOtherClass)\n```\n\nThis syntax also works to call functions:\n```yaml\n# config.yml\n(): \"my_project.my_function\"\nmy_argument: \"world\"\n```\n\n```python\nimport configue\n\ndef my_function(my_argument: str) -\u003e str:\n  return \"Hello \" + my_argument\n\nmy_value = configue.load(\"config.yml\")\nassert my_value == \"Hello world\"\n```\n\n### Loading external variables\n\n```yaml\n# config.yml\nmy_argument: !ext my_project.my_module.my_variable\nmy_argument: !ext my_project.my_module.my_instance.my_attribute\n```\n\nWhen using the `!ext` tag, the value will be imported from the corresponding python module.\n\n\n### Loading internal variables\n\n```yaml\n# config.yml\nmy_object:\n    my_instance:\n        (): my_project.MyClass\nmy_instance_shortcut: !cfg my_object.my_instance\nmy_attribute_shortcut: !cfg my_object.my_instance.my_attribute\n```\n\nWhen using the `!cfg` tag, the value will be loaded from the same configuration file (useful for a DRY configuration).\n\n### Environment variables\n\nIf you want to load an environment variable in your YAML config file, you can use this syntax:\n```yaml\n# config.yml\nmy_key: ${VAR_NAME}\n```\nThis will resolve as `\"my_value\"` if the environment variable `VAR_NAME` is set to this value.\n\nIf you need a default value in case the environment variable is not set:\n```yaml\n# config.yml\nmy_key: ${VAR_NAME-default}\n```\n\nYou can insert this syntax in the middle of a string:\n```yaml\n# config.yml\nmy_key: prefix${VAR_NAME-default}suffix\n```\nThis will resolve as `\"prefixmy_value_suffix\"` if the value is set, `\"prefixdefaultsuffix\"` if it is not.\n\nIf your environment variable resolves to a yaml value, it will be cast (unless you are using quotes):\n```yaml\n# config.yml\nmy_key: ${VAR_NAME}\nmy_quoted_key: \"${VAR_NAME}\"\n```\nThis will resolve as `True` if the value is set to `true`, `yes` or `y`, `None` if the value is set to `~` or `null`.\n\n\n### Relative paths\n\nIf you want to expand a relative path in your YAML config file:\n\n````yaml\n# config.yml\nmy_path: !path my_folder/my_file.txt  \n````\nAssuming your file structure looks like this:\n```\nroot/\n├── config.yml\n└── my_folder\n    └── my_file.txt\n```\n\nThe path is resolved starting from the folder containing the parent yml file, this example will resolve to\n`/root/my_folder/my_file.txt`\n\nDo not start the path with `/` as it will be treated as an absolute path instead.\n\nYou can use environment variables in your file path.\n\n### Importing other files\n\nYou can import another file directly in your YAML config file:\n\n````yaml\n# config.yml\nmy_import: !import my_folder/my_other_config.yml\n````\n\n```yaml\n# my_other_config.yml\nsome_key:\n    - var_1\n    - var_2\n```\n\nBy default, the path is resolved starting from the folder containing the parent yml file, this example will resolve to\n`\"my_import\": {\"some_key\": [var_1, var_2]}`\n\nIf you want to import only a section of the file, use the path in the tag suffix `!import:some_key.0`\n\nDo not start the import path with `/` as it will be treated as an absolute path instead.\n\nYou can use environment variables in your import path.\n\n### Logging configuration\n\nYou can load the logging configuration for your application by using the `logging_config_path` parameter:\n```yaml\n# config.yml\nlogging_config:\n  version: 1\n  handlers:\n    console:\n      class : logging.StreamHandler\n      stream  : ext://sys.stdout\n    custom_handler:\n      \\(): my_app.CustomHandler\n      some_param: some_value\n      level: ERROR\n  root:\n    level: INFO\n    handlers:\n      - console\n\napp_config:\n  some_key: some_value\n\nnot_loaded_key: not_loaded_value\n```\n\n```python\nimport logging\n\nimport configue\n\napp_config = configue.load(\"config.yml\", \"app_config\", logging_config_path=\"logging_config\")\nassert app_config == {\"some_key\": \"some_value\"}\n\nlogger = logging.getLogger(__name__)\nlogger.info(\"Hello world!\")  # Uses the console handler\n```\n\nThe logging configuration should follow the format of `logging.config.dictConfig`\n(check [the documentation](https://docs.python.org/3/library/logging.config.html#logging-config-dictschema) for more\ndetails).\nMake sure to escape the constructors with `\\()` instead of `()` for handlers, formatters and filters.\n\n\n# Testing\n\nInstall the development dependencies with `pip install -r dev.requirements.txt`.\n\nRun `python -m unitttest discover` to run the tests.\n\nRun `pylint configue` to check the files linting.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filluin-tech%2Fconfigue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filluin-tech%2Fconfigue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filluin-tech%2Fconfigue/lists"}