Envargs
Simple means of parsing and validating environment variables. Heavily inspired by the earlier versions of webargs, which also explains the name to some extend.
Installing
$ pip install envargs
Using
from envargs import Var, parse_env
required_vars = {
'A_INT': Var(
use=int,
validate=lambda x: x >= 0,
),
'A_LIST': Var(
use=lambda x: x.split(','),
validate=(
lambda x: len(x) == 2,
lambda x: x[0] == 'first element',
),
),
'A_STR': Var(
use=str,
load_from='SOME_OTHER_NAME',
validate=bool,
),
}
parsed = parse_env(required_vars)
Say you want to configure your Flask app using this:
app.config.from_mapping(parsed)
Why reinvent the wheel again?
To be fair there are many good packages out there to parse environment variables, quite a few of them in python too. So this package can easily be seen as redundant. However, with separation of parsing and validation into two separate functions, you gain more power to control what is actually accepted, not to mention that it makes it possible to inline a few more things, as you can most often get away with using builtin functions for most parsing and validation, and when that is not enough, lambdas or partials can do the rest.
Metadata
Release files for envargs 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| envargs-0.2.1.tar.gz | 3.9 kB | Without provenance | Details for envargs-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| envargs-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for envargs-0.2.1-py3-none-any.whl |
Total release size: 9.6 kB
Release files / envargs-0.2.1.tar.gz
| Download URL | envargs-0.2.1.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86feca1c12b86b66143ad9f5e7098c53ebecb99b72a7b457a4e1a4c5c947672a
|
|
BLAKE2b-256 checksum How to use checksums |
a3aa13e89c4518c39e2fe18027d236aa22a297fb7956b2ecdc8a1314f710e9a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / envargs-0.2.1-py3-none-any.whl
| Download URL | envargs-0.2.1-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5579d8307adcea29e14aa0b7c0d1402f8a0b102b04bd8aa593a571f53ea672ea
|
|
BLAKE2b-256 checksum How to use checksums |
1e6ff4ad204152e995dc9e510ea641d48e5888a755a71063f5b33d8aeb50dc62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for envargs 0.2.1
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.