Skip to main content

env_fields

codecov CI

Dataclass fields with getting values from environment by default

Install it from PyPI

pip install env_fields

Usage

import os
from dataclasses import field, dataclass
from env_fields import (
    env_field_int,
    env_field_str,
    env_field,
)


@dataclass
class SomeClass:
    attribute_1: int = field()
    attribute_2: int = env_field_int('SOME_INT_ENVIRONMENT_VARIABLE')
    attribute_3: str = env_field_str('SOME_STR_ENVIRONMENT_VARIABLE')
    attribute_4: str = env_field_str(
        'SOME_STR_ENVIRONMENT_VARIABLE_THAT_NOT_SET',
        default="hello, world"
    )
    attribute_5: int = env_field("SOME_CUSTOM_TYPE_ENV_VARIABLE", float, init=False)

Let's create some dataclass!

>>> os.environ['SOME_INT_ENVIRONMENT_VARIABLE'] = "1234"
>>> os.environ['SOME_STR_ENVIRONMENT_VARIABLE'] = "hello, world 1"
>>> os.environ['SOME_CUSTOM_TYPE_ENV_VARIABLE'] = "2.59"
>>> SomeClass(12)
SomeClass(
    attribute_1=12,
    attribute_2=1234,
    attribute_3='hello, world 1',
    attribute_4='hello, world',
    attribute_5=2.59,
)

Development

Read the CONTRIBUTING.md file.

Metadata

Release files for env-fields 0.2.0

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

Source distribution (sdist)

Source distribution for env-fields 0.2.0
File Size Uploaded Provenance Actions
env_fields-0.2.0.tar.gz 4.2 kB Without provenance Details for env_fields-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for env-fields 0.2.0
File Interpreter ABI Platform Actions
env_fields-0.2.0-py3-none-any.whl Python 3 none any Details for env_fields-0.2.0-py3-none-any.whl

Total release size: 7.8 kB

Release files / env_fields-0.2.0.tar.gz

Download URL env_fields-0.2.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1876d1ef570340956e5fec07097555e8ab4efc89ea39b0a363759f9c163d7083
BLAKE2b-256 checksum
How to use checksums
e17f7cbc3e64d75451879af24a3ef825aab01e5c38e3698b31f040ad9a9975f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release files / env_fields-0.2.0-py3-none-any.whl

Download URL env_fields-0.2.0-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c393b8f6b660332e6af1300591fef2c22bf5154a2f60613472d24b0ed5698928
BLAKE2b-256 checksum
How to use checksums
efc60208cfdc8786269fb54bccc51448f1748873d44eb1bbba413598c58f06b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Security for env-fields 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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