envmix


Nameenvmix JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryPydantic v2 mixin to load settings from environment variables with robust casting
upload_time2025-10-20 03:42:01
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2025 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords config dotenv environment pydantic settings
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            envmix
=====

Typed environment loader for Pydantic v2 models.

Features
- **Simple**: `from_env()` fills fields from overrides > env vars > defaults
- **Typed**: ships `py.typed`; works nicely with type checkers
- **Robust casting**: JSON-first via TypeAdapter; CSV and k=v fallbacks

Install
```bash
pip install envmix
```

Quick start
```python
from pydantic import BaseModel
from envmix import EnvMixModel

class DB(BaseModel):
    host: str
    port: int

class Settings(EnvMixModel):
    __env_prefix__ = "APP_"
    host: str = "127.0.0.1"
    port: int = 8080
    debug: bool = False

# export APP_PORT=5000 APP_DEBUG=true
s = Settings.from_env()
print(s.port)  # 5000
print(s.debug) # True
```

Custom env key per field
```python
from pydantic import Field

class Settings(EnvMixModel):
    server_host: str = Field("0.0.0.0", json_schema_extra={"env": "SERVER_HOST"})
```

License
MIT

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "envmix",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "config, dotenv, environment, pydantic, settings",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/b3/42/aa45127d0b282575bea4e5e91e8c66d3e11bdec807c359ae5bcfeeaf9017/envmix-0.1.0.tar.gz",
    "platform": null,
    "description": "envmix\n=====\n\nTyped environment loader for Pydantic v2 models.\n\nFeatures\n- **Simple**: `from_env()` fills fields from overrides > env vars > defaults\n- **Typed**: ships `py.typed`; works nicely with type checkers\n- **Robust casting**: JSON-first via TypeAdapter; CSV and k=v fallbacks\n\nInstall\n```bash\npip install envmix\n```\n\nQuick start\n```python\nfrom pydantic import BaseModel\nfrom envmix import EnvMixModel\n\nclass DB(BaseModel):\n    host: str\n    port: int\n\nclass Settings(EnvMixModel):\n    __env_prefix__ = \"APP_\"\n    host: str = \"127.0.0.1\"\n    port: int = 8080\n    debug: bool = False\n\n# export APP_PORT=5000 APP_DEBUG=true\ns = Settings.from_env()\nprint(s.port)  # 5000\nprint(s.debug) # True\n```\n\nCustom env key per field\n```python\nfrom pydantic import Field\n\nclass Settings(EnvMixModel):\n    server_host: str = Field(\"0.0.0.0\", json_schema_extra={\"env\": \"SERVER_HOST\"})\n```\n\nLicense\nMIT\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2025  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  ",
    "summary": "Pydantic v2 mixin to load settings from environment variables with robust casting",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/c0sogi/envmix",
        "Issues": "https://github.com/c0sogi/envmix/issues"
    },
    "split_keywords": [
        "config",
        " dotenv",
        " environment",
        " pydantic",
        " settings"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d5d5c2b1ca75e0311952e4a9b3870a04e6163cb646f263f2ec19b93a31bd121c",
                "md5": "b43a892ed052f641c87c84189dcd59bb",
                "sha256": "9665656ff6879159cf995cd5ed8ca25300b26cb68efef6ba538dd2ee5b044a4e"
            },
            "downloads": -1,
            "filename": "envmix-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b43a892ed052f641c87c84189dcd59bb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 5560,
            "upload_time": "2025-10-20T03:41:59",
            "upload_time_iso_8601": "2025-10-20T03:41:59.967782Z",
            "url": "https://files.pythonhosted.org/packages/d5/d5/c2b1ca75e0311952e4a9b3870a04e6163cb646f263f2ec19b93a31bd121c/envmix-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b342aa45127d0b282575bea4e5e91e8c66d3e11bdec807c359ae5bcfeeaf9017",
                "md5": "d579b079b3954594b857402fc0830b23",
                "sha256": "cef193f3b1a5b205baf67490bab69ed812d5e331aaf2ddac7891559f7454b9b7"
            },
            "downloads": -1,
            "filename": "envmix-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d579b079b3954594b857402fc0830b23",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 4352,
            "upload_time": "2025-10-20T03:42:01",
            "upload_time_iso_8601": "2025-10-20T03:42:01.395267Z",
            "url": "https://files.pythonhosted.org/packages/b3/42/aa45127d0b282575bea4e5e91e8c66d3e11bdec807c359ae5bcfeeaf9017/envmix-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-20 03:42:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "c0sogi",
    "github_project": "envmix",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "envmix"
}
        
Elapsed time: 1.06106s