{"id":27633,"library":"cattrs-env","title":"cattrs-env","description":"A Python library for parsing and validating environment variables using cattrs structured configuration. Version 1.0.4 supports Python >=3.7. Released under MIT license. Low release cadence.","status":"active","version":"1.0.4","language":"python","source_language":"en","source_url":"https://github.com/henryivesjones/cattrs-env","tags":["environment-variables","cattrs","validation","configuration"],"install":[{"cmd":"pip install cattrs-env","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for structured parsing/validation of env vars.","package":"cattrs","optional":false},{"reason":"Used to define data classes with cattrs.","package":"attrs","optional":false}],"imports":[{"wrong":"from cattrs_env import EnvSettings","symbol":"CattrsEnv","correct":"from cattrs_env import CattrsEnv"}],"quickstart":{"code":"from attrs import define\nfrom cattrs_env import EnvSettings\n\n@define\nclass Config:\n    host: str = 'localhost'\n    port: int = 8080\n\nconfig = EnvSettings(Config).parse_env()\nprint(config.host, config.port)\n","lang":"python","description":"Define an attrs class and use EnvSettings to automatically populate fields from environment variables with matching names (e.g., HOST, PORT)."},"warnings":[{"fix":"Use the 'var_name' argument in the field metadata to override: host: str = field(metadata={'var_name': 'MY_HOST'})","message":"Environment variable names are uppercased by default. A field 'host' expects env var 'HOST'.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure env var values are valid Python literals (e.g., no extra whitespace, quotes for strings). Use the 'type' argument if you need explicit control.","message":"cattrs-env uses ast.literal_eval to parse string values (e.g., '8080' becomes int). If the string is not a valid Python literal, it falls back to str type without warning. This can silently misparse values like '8080 ' (with trailing space) as string.","severity":"gotcha","affected_versions":"*"},{"fix":"N/A","message":"No deprecations known.","severity":"deprecated","affected_versions":"N/A"}],"env_vars":null,"search_vec":"'1.0.4':18 '3.7':21 'cadenc':28 'cattr':2,14,32 'cattrs-env':1 'configur':16,34 'env':3 'environ':11,30 'environment-vari':29 'librari':6 'licens':25 'low':26 'mit':24 'pars':8 'python':5,20 'releas':22,27 'structur':15 'support':19 'use':13 'valid':10,33 'variabl':12,31 'version':17","created_at":"2026-05-09T05:51:17.166643+00:00","updated_at":"2026-05-09T05:51:17.166643+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/henryivesjones/cattrs-env","docs":null,"changelog":null,"pypi":"https://pypi.org/project/cattrs-env/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-08-02","install_tag":null}}