Skip to main content

Enviparse

CI codecov

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 :

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 :

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.

Release files for enviparse 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for enviparse 2.0.1
File Size Uploaded
enviparse-2.0.1.tar.gz 14.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for enviparse 2.0.1
File Interpreter ABI Platform
enviparse-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.2 kB

Release files / enviparse-2.0.1.tar.gz

Download URL enviparse-2.0.1.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
dde9ad3411022605215e999ca2bf1282ce366f67287e54234a35562f28cdd0e2
BLAKE2b-256 checksum
How to use checksums
c0c1d4ce843eb3d2d639ea7176163419e92f467599416672896f85584de76eed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release files / enviparse-2.0.1-py3-none-any.whl

Download URL enviparse-2.0.1-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60343608ff18f87f378aa8e5a9faa1f0d808b9624fe281898489d80f8da08b02
BLAKE2b-256 checksum
How to use checksums
f217dd61de2837fc027c5fe2464abc4c1924d58a83e780ca0fe31e06599e7dd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page