{"id":17560154,"url":"https://github.com/vd2org/envreader","last_synced_at":"2025-06-20T12:34:18.256Z","repository":{"id":57426653,"uuid":"303472965","full_name":"vd2org/envreader","owner":"vd2org","description":"Environment variables parser with types! Yes!","archived":false,"fork":false,"pushed_at":"2024-02-05T07:36:44.000Z","size":53,"stargazers_count":12,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-28T10:56:15.952Z","etag":null,"topics":["env","environment","environment-variables","python3","types"],"latest_commit_sha":null,"homepage":"","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/vd2org.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2020-10-12T18:03:39.000Z","updated_at":"2024-09-11T23:48:27.000Z","dependencies_parsed_at":"2025-04-18T03:54:30.044Z","dependency_job_id":"26d4ca87-f18e-4b12-a981-b945ab0d5eca","html_url":"https://github.com/vd2org/envreader","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/vd2org/envreader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vd2org%2Fenvreader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vd2org%2Fenvreader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vd2org%2Fenvreader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vd2org%2Fenvreader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vd2org","download_url":"https://codeload.github.com/vd2org/envreader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vd2org%2Fenvreader/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260945249,"owners_count":23086978,"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","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":["env","environment","environment-variables","python3","types"],"created_at":"2024-10-21T11:23:54.576Z","updated_at":"2025-06-20T12:34:13.243Z","avatar_url":"https://github.com/vd2org.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EnvReader\n\nEnvironment variables parser with types! Yes!\n\nEvery time when you make new service you need some class to receive, validate and store environment variables.\n\nWith this package it’ll be easy and funny.\n\nJust make a class with typed fields and... that’s it.\n\n### Requirements\n\nPython 3.7 and above. There's no additional dependencies.\n\n### Installation\n\n`pip install envreader`\n\n### Simple usage\n\n```python\nfrom envreader import EnvReader\n\n\nclass MyEnv(EnvReader):\n    PATH: str\n    LIST: list\n    NONE_EXIST: int = 1234  # Variable with default value\n\n\ne = MyEnv()\n\nprint(e.PATH)\n# /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin\n\nprint(e.LIST)\n# [1, 2, 3, 4]\n\nprint(e.NONE_EXIST)\n# 1234\n```\n\n### Use with transform functions\n\nI don’t want to make a giant validation library like wonderful **Pydantic**. Thus EnvReader supports only simple types(\nbool, str, int, float, list, tuple and dict) by default. This is enough in most cases.\n\nTransform functions allows using EnvReader for more complex cases.\n\n```python\nfrom typing import List\nfrom envreader import EnvReader, Field\n\n\nclass MyEnv(EnvReader):\n    PATH: List[str] = Field(transform=lambda x: x.split(\":\"))\n\n\ne = MyEnv()\n\nprint(e.PATH)\n# ['/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin']\n```\n\n### Using static methods as a transform functions.\n\nYou may store all your helper functions inside the same class. But don’t forget to add @staticmethod decorator.\n\n```python\nfrom typing import List\nfrom envreader import EnvReader, Field\n\n\nclass MyEnv(EnvReader):\n    @staticmethod\n    def trans(x: str) -\u003e List[str]:\n        return x.split(':')\n\n    PATH: List[str] = Field(transform=trans)\n\n\ne = MyEnv()\n\nprint(e.PATH)\n# ['/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin']\n```\n\n### Make your environment variables self-documented.\n\nDocumentation is in great demand for all good applications, right?\n\n```python\nfrom envreader import EnvReader, Field\n\n\nclass MyEnv(EnvReader):\n    PATH: str = Field(\"/sbin\", description=\"Application path\", example=\"/usr/bin:/bin:/usr/sbin:/sbin\")\n\n\ne = MyEnv()\n\nprint(e.help())\n# PATH\n#     Application path\n#     Example: /usr/bin:/bin:/usr/sbin:/sbin\n#     Default: /sbin\n```\n\n### Error handling? Easy.\n\n```python\nimport sys\nfrom envreader import EnvReader, EnvMissingError\n\n\nclass MyEnv(EnvReader):\n    SOME_VAR: str\n\n\ntry:\n    e = MyEnv()\nexcept EnvMissingError as e:\n    print(f\"Missing required env var {e.field}\")\n    sys.exit(-1)\n# Missing required env var SOME_VAR\n```\n\n#### Enjoy!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvd2org%2Fenvreader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvd2org%2Fenvreader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvd2org%2Fenvreader/lists"}