Utilities for building applications.
Contains:
- Config loading from environment
- Bootstrap for logging
- Base class for creating async workers
- Async timeout decorator, which is very useful for writing async tests
Examples:
Env config
import os
from datek_app_utils.env_config.base import BaseConfig
# Just for demonstration, of course env vars shouldn't be set in python
os.environ["COLOR"] = "RED"
os.environ["TEMPERATURE"] = "50"
os.environ["DISABLE_AUTOTUNE"] = "y"
class Config(BaseConfig):
COLOR: str
TEMPERATURE: int
DISABLE_AUTOTUNE: bool
assert Config.COLOR == "RED"
assert Config.TEMPERATURE == 50
assert Config.DISABLE_AUTOTUNE is True
The Config class casts the values automatically.
Moreover, you can test whether all the mandatory variables have been set or not.
import os
from datek_app_utils.env_config.base import BaseConfig
from datek_app_utils.env_config.utils import validate_config
from datek_app_utils.env_config.errors import ValidationError
os.environ["COLOR"] = "RED"
os.environ["DISABLE_AUTOTUNE"] = "I can't sing but I pretend to be a singer"
class Config(BaseConfig):
COLOR: str
TEMPERATURE: int
AMOUNT: int = None
DISABLE_AUTOTUNE: bool = None
try:
validate_config(Config)
except ValidationError as error:
for attribute_error in error.errors:
print(attribute_error)
Output:
DISABLE_AUTOTUNE: Invalid value. Required type: <class 'bool'>
TEMPERATURE: Not set. Required type: <class 'int'>
Async timeout decorator
from asyncio import sleep, run
from datek_app_utils.async_utils import async_timeout
@async_timeout(0.1)
async def sleep_one_sec():
await sleep(1)
run(sleep_one_sec())
Output:
TimeoutError
Metadata
Release files for datek_app_utils 0.4.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 |
|---|---|---|---|---|
| datek_app_utils-0.4.0.tar.gz | 4.7 kB | Without provenance | Details for datek_app_utils-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| datek_app_utils-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for datek_app_utils-0.4.0-py3-none-any.whl |
Total release size: 12.7 kB
Release files / datek_app_utils-0.4.0.tar.gz
| Download URL | datek_app_utils-0.4.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
23d8526663be6c4c7c057b4ee771f406a3041cfb7d3f625cf55167bb3540226e
|
|
BLAKE2b-256 checksum How to use checksums |
489b44e73124c5704cb7b5b23e62dd9adda78b093ea8381d7075b1c0eaeeb5c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.9.16 Linux/6.5.0-1021-azure
|
Release files / datek_app_utils-0.4.0-py3-none-any.whl
| Download URL | datek_app_utils-0.4.0-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8331797b59ac63f0ff241404c041c9e255ee34b372036351353167eef5abed5
|
|
BLAKE2b-256 checksum How to use checksums |
2ef0ad2dc93d4507223b154616fa10e7cd3e496096a828312e5cfc550a88bc85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.9.16 Linux/6.5.0-1021-azure
|
Security for datek_app_utils 0.4.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.