{"id":23087,"library":"environ-config","title":"environ-config","description":"A Python library for boilerplate-free configuration using environment variables. Current version 24.1.0 (released 2024-10-27) with type annotations, minimal setup, and a decorator-based approach. Maintenance release with tests/docs updates.","status":"active","version":"24.1.0","language":"python","source_language":"en","source_url":"https://github.com/hynek/environ-config","tags":["configuration","environment-variables","type-hints","12-factor"],"install":[{"cmd":"pip install environ-config","lang":"bash","label":"default"}],"dependencies":[],"imports":[{"note":"The package name on PyPI is 'environ-config' but the import module is 'environ'. Using 'environ_config' will raise ModuleNotFoundError.","wrong":"import environ_config","symbol":"environ-config","correct":"import environ"},{"note":"Common but the correct way is to import the config class directly. Both work, but direct import is idiomatic.","wrong":"import environ; environ.config()","symbol":"environ.config","correct":"from environ import config"}],"quickstart":{"code":"import os\nfrom environ import config\n\n@config\nclass MyConfig:\n    prefix = 'MYAPP'\n    host: str\n    port: int = 8080\n\ncfg = MyConfig()\nprint(f'Host: {cfg.host}, Port: {cfg.port}')\nos.environ['MYAPP_HOST'] = 'example.com'\nos.environ['MYAPP_PORT'] = '9090'\ncfg2 = MyConfig()\nprint(f'Host: {cfg2.host}, Port: {cfg2.port}')","lang":"python","description":"Define a configuration class with a decorator. Annotate fields; they are automatically populated from environment variables with the given prefix. Defaults are allowed."},"warnings":[{"fix":"Create a fresh config object when you need updated values, or use a singleton pattern that re-reads on each access.","message":"Environment variables are read at class instantiation time, not import time. The values are fixed once the object is created; subsequent changes to env vars require a new instance.","severity":"gotcha","affected_versions":"all"},{"fix":"Always add type annotations to config fields, e.g., host: str.","message":"As of 23.1.0, type annotations are required for all fields. Omitting type hint will raise a TypeError.","severity":"deprecated","affected_versions":">=23.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'import environ' instead.","cause":"The package name is 'environ-config' but the import module is 'environ'.","error":"ModuleNotFoundError: No module named 'environ_config'"},{"fix":"Ensure the class decorated with @config does not inherit from another class unless it's also a config class.","cause":"Using @config on a class that is a subclass of something other than object, or misusing the decorator.","error":"TypeError: __init_subclass__() missing 1 required positional argument: 'cls'"},{"fix":"Set the environment variable or provide a default in the field definition (e.g., host: str = 'localhost').","cause":"The environment variable is not set and there is no default value.","error":"AttributeError: 'MyConfig' object has no attribute 'host'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}