castaway
A simple wrapper for python-dotenv that allows for easy casting of environment strings to various data types.
Installation
Standard install:
pip install castaway
If you want Django integration (dj-email-url, dj-database-url), do:
pip install castaway[django]
Example
Easiest form is:
from castaway import config
SOME_SETTING = config('SOME_SETTING', default=None)
Like python-dotenv, this will load .env from the current working directory, or walk the parent directory tree until it is found.
For more custom usage, you can specify the exact name and path to whatever file you need. For instance, using the tests/.env file from this repo.
from datetime import datetime
from castaway import Config
config = Config('tests/.env')
CASTAWAY_INT = config('CASTAWAY_INT', cast=int)
assert CASTAWAY_INT == 23
CASTAWAY_LIST = config('CASTAWAY_LIST', cast=list)
assert CASTAWAY_LIST == ['a', 'b', 'c']
CASTAWAY_DATETIME = config('CASTAWAY_DATETIME', cast=datetime.fromisoformat)
assert CASTAWAY_DATETIME == datetime(2021, 4, 3, 14, 25)
Metadata
Release files for castaway 1.1.0
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 |
|---|---|---|---|---|
| castaway-1.1.0.tar.gz | 4.7 kB | Without provenance | Details for castaway-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| castaway-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for castaway-1.1.0-py3-none-any.whl |
Total release size: 8.9 kB
Release files / castaway-1.1.0.tar.gz
| Download URL | castaway-1.1.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12ac394fa5985348d83aa030737baaf092b7c8818372a1f708680ef9ab236f58
|
|
BLAKE2b-256 checksum How to use checksums |
312b7af11ca3474480c6bb70c3541bc12d3c61880b93e1f97ad2a1293644561a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.13
|
Release files / castaway-1.1.0-py3-none-any.whl
| Download URL | castaway-1.1.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
41c9e38bcca397de4569f343050617f78a7f06fbd8d08c8a2f0730cc086df109
|
|
BLAKE2b-256 checksum How to use checksums |
c514fa8e3f63eea1665a2f910854becf5369b25149609a834a86523f1d5836ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.13
|
Security for castaway 1.1.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.