Walter
Walter is a configuration library, inspired by python-decouple, and intended to replace direct access to os.environ in Django settings.py files (although it is by no means Django-specific). It currently supports Python 3.6+.
It differs from other, similar libraries for one reason: when your users try to start up your app with invalid configuration, the error message they get shows a list of all of the errors with every configuration parameter, not just the first one.
Installation
pip install walter
# or
poetry add walter
Usage
Here’s an example of a Python file that uses Walter to define its configuration.
from walter.config import Config
with Config(author="Acme Inc.", name="My Awesome App") as config:
# Read a configuration value with config()
SECRET_KEY = config('SECRET_KEY')
# Convert the returned value to something other than a string with cast.
DEBUG = config('DEBUG', cast=bool)
# You can pass any function that takes a string to `cast`.
# Here, we're using a third party function to parse a database URL
# string into a Django-compatible dictionary.
import dj_database_url
DATABASES = {
'default': config('DATABASE_URL', cast=dj_database_url.parse),
}
# You can also make a parameter optional by giving it a default.
SENTRY_DSN = config('SENTRY_DSN', default=None)
print(f"Here, you can use values like {SITE_NAME}!")
If we run that code without setting anything, Walter throws an error at the end of the with block.
Traceback (most recent call last):
File "<stdin>", line 27, in <module>
File "/Users/leigh/Projects/walter/walter/config.py", line 90, in __exit__
raise ConfigErrors(errors=self.errors)
walter.config.ConfigErrors: 4 configuration values not set, 0 invalid
SECRET_KEY not set
DEBUG not set
DATABASE_URL not set
SITE_NAME not set
Note that Walter lists out all of the errors in our configuration, not just the first one! If we set all of those settings as environment variables and run the code again, the code runs to completion:
Here, you can use values like MyAwesomeApp!
Metadata
Release files for walter 1.2
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 |
|---|---|---|---|---|
| walter-1.2.tar.gz | 16.7 kB | Without provenance | Details for walter-1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| walter-1.2-py3-none-any.whl | Python 3 | none | any | Details for walter-1.2-py3-none-any.whl |
Total release size: 34.1 kB
Release files / walter-1.2.tar.gz
| Download URL | walter-1.2.tar.gz |
|---|---|
| Size | 16.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36f2d010bd7261781576199d0fd5b948b2a3d2b29fd022e72931f3293ee01c79
|
|
BLAKE2b-256 checksum How to use checksums |
d4f7f95fdc26efaf6e099325d4a1498103f08058c3d131b294a4b9a142f1b45a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.8.2 Darwin/19.4.0
|
Release files / walter-1.2-py3-none-any.whl
| Download URL | walter-1.2-py3-none-any.whl |
|---|---|
| Size | 17.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc1ea414f3c721cdca4f3af749f43acae1d5bb694dcfef99b1912bba5e15a358
|
|
BLAKE2b-256 checksum How to use checksums |
f7e5abdfd923e7dcb9d8e0ebe59c7b04e4ad804edf10c1bc0867241a0962a3f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.8.2 Darwin/19.4.0
|
Security for walter 1.2
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.