https://github.com/illuin-tech/enviparse
Configuration parsing library from environment variables
https://github.com/illuin-tech/enviparse
Last synced: about 1 year ago
JSON representation
Configuration parsing library from environment variables
- Host: GitHub
- URL: https://github.com/illuin-tech/enviparse
- Owner: illuin-tech
- License: mit
- Created: 2024-08-23T06:11:09.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-24T12:52:00.000Z (about 1 year ago)
- Last Synced: 2025-03-27T23:51:04.399Z (about 1 year ago)
- Language: Python
- Size: 113 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Enviparse

[](https://codecov.io/gh/illuin-tech/enviparse)
## Description
Enviparse let you simply create dataclasses from environment variable.
Supported types are :
* int
* float
* str
* bool
* optional
* list
* enum (with int or string values only)
* `@attr` annotated class
* `@dataclasses.dataclass` annotated class
# Example
With following environment variables :
```bash
DATABASE_CONFIG_USERNAME=postgres
DATABASE_CONFIG_PASSWORD=password
DATABASE_CONFIG_HOST=127.0.0.1
DATABASE_CONFIG_PORT=5432
DATABASE_CONFIG_DATABASE_NAME=appdb
```
You can parse environment variable with :
```python
import dataclasses
from enviparse import Enviparse
@dataclasses.dataclass
class DatabaseConfig:
username: str
password: str
host: str
port: int
database_name: str
db_config = Enviparse().parse("DATABASE_CONFIG", DatabaseConfig)
print(db_config)
```
You should get the following result :
```
DatabaseConfig(username='postgres', password='password', host='127.0.0.1', port=5432, database_name='appdb')
```
For more example see the [test folder](./tests).