Skip to content
/ enva Public

Utilities for working with environment variables in Python

License

Notifications You must be signed in to change notification settings

TTitcombe/enva

Repository files navigation

Enva

Making working with environment variables in Python slightly better.

Ever needed to get an environment variable as an integer or a boolean? Ever needed to assert that an environment variable is set? Stop looking at the standard library. It can't help you. enva can.

enva provides utility functionality for working with environment variables in Python. There are two main features:

  • Variable retrieval (as alternative types, e.g. int)
  • Variable assertion (e.g. is the variable set)

Sponsor

This project is sponsored by Documatic, the search engine for your codebase.

Getting started

Requirements

  • Python 3.9 or greater
  • That's it

Install enva from pypi with

pip install enva

Updates

Please refer to the changelog for a full breakdown of recent updates.

Examples

Converting env vars

import os
from enva.getters import get_env_int

os.environ["SOME_VAR"] = "10"

print(get_env_int("SOME_VAR"))  # 10 (as an int)

Verifying env var types

import os
from enva.checkers import require_variable_as_type

os.environ["SOME_VAR"] = "10"
os.environ["ANOTHER_VAR"] = "ten"

print(require_variable_as_type("SOME_VAR", float))  # No throw
print(require_variable_as_type("ANOTHER_VAR", float))  # Will raise

Developers

Code quality

  • black formatting
  • isort imports
  • mypy compliance

Testing

Unit tests are run with pytest. Please ensure that new features and bug fixes have an appropriate test. There is a github action to ensure tests pass with sufficient coverage.

Contributing

All contributions are welcome! Please see the contributing guide to get started.

License

GPL-3. Please read the license for full terms.

About

Utilities for working with environment variables in Python

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages