Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ttitcombe/enva
Utilities for working with environment variables in Python
https://github.com/ttitcombe/enva
env environment environment-variables utility
Last synced: 14 days ago
JSON representation
Utilities for working with environment variables in Python
- Host: GitHub
- URL: https://github.com/ttitcombe/enva
- Owner: TTitcombe
- License: gpl-3.0
- Created: 2022-11-11T14:10:56.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-12-17T23:26:52.000Z (about 2 years ago)
- Last Synced: 2024-11-07T06:32:52.054Z (2 months ago)
- Topics: env, environment, environment-variables, utility
- Language: Python
- Homepage:
- Size: 31.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://app.documatic.com),
the search engine for your codebase.# Getting started
## Requirements
* Python 3.9 or greater
* That's itInstall enva from pypi with
```
pip install enva
```## Updates
Please refer to the [changelog](./CHANGELOG.md)
for a full breakdown of recent updates.# Examples
## Converting env vars
```python
import os
from enva.getters import get_env_intos.environ["SOME_VAR"] = "10"
print(get_env_int("SOME_VAR")) # 10 (as an int)
```## Verifying env var types
```python
import os
from enva.checkers import require_variable_as_typeos.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](./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](./CONTRIBUTING.md)
to get started.# License
GPL-3.
Please read [the license](./LICENSE)
for full terms.