Add readability and self-documentation to Python code
Project description
readables-py
Enhance code readability and self-documentation in our Python code
Distributed Lock
[!NOTE] Check out the dedicated documentation.
Environment Variable Manager and Exporter
Declare and retrieve variables
Here is how you can declare and retrieve variables.
# file: your_app/constants.py
from readables.env import required_env, optional_env, flag
ALPHA = required_env('ALPHA', help='Alpha variable')
BETA = optional_env('BETA', 'default_value', help='Beta variable')
CHARLIE = flag('CHARLIE', help='Charlie flag')
[!TIP] When
required_envis used, if the variable is not set, it will raise an exception.
Export variables
We have provided two exporters: the env file exporter and the MarkDown exporter. If you are working on the code that
the required environment variables have not been set, you will need to set READABLES_ENV_ALLOW_UNSET_REQUIRED to true
before using an exporter to suppress the error.
In this example, we use the env file exporter to generate the content of the distributed env file using the content above.
# file: scripts/gen_dist_env.py
from os import environ
environ['READABLES_ENV_ALLOW_UNSET_REQUIRED'] = 'true'
# noinspection PyUnresolvedReferences
from your_app import constants
from readables.env import manager, EnvFileExporter
output = EnvFileExporter.export(manager.variables)
[!NOTE] An exporter does not know how to scan the code. So, you need to find the way to ensure that the manager knows the declared variables. In this example, it imports any references to the "static" variables.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file readables_py-0.2.4.tar.gz.
File metadata
- Download URL: readables_py-0.2.4.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af2bc98f174362e8d39ad790f98766d34f022214490c3b9f7cb5450ec80195cb
|
|
| MD5 |
8244f446dd4f17ba2c19efdf017791d2
|
|
| BLAKE2b-256 |
4cf2b12fd5efdedd15a64be63bcdc004ec899367d07e04ad9da54eccab49795c
|
Provenance
The following attestation bundles were made for readables_py-0.2.4.tar.gz:
Publisher:
package-release.yml on shiroyuki/readables-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
readables_py-0.2.4.tar.gz -
Subject digest:
af2bc98f174362e8d39ad790f98766d34f022214490c3b9f7cb5450ec80195cb - Sigstore transparency entry: 1072702705
- Sigstore integration time:
-
Permalink:
shiroyuki/readables-py@0987dda712a031cc0368f03c960d71c7a9e3ad77 -
Branch / Tag:
refs/tags/0.2.4 - Owner: https://github.com/shiroyuki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package-release.yml@0987dda712a031cc0368f03c960d71c7a9e3ad77 -
Trigger Event:
release
-
Statement type:
File details
Details for the file readables_py-0.2.4-py3-none-any.whl.
File metadata
- Download URL: readables_py-0.2.4-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a67aedac72a49049ba25d04813d38b0e4427d1af871d828cef913e0652beb1b4
|
|
| MD5 |
34f8961bec0c0bf339c53f4bdeb616b2
|
|
| BLAKE2b-256 |
9e6fa26fb0e569d7a95b5a67be264a32ac4eb6bdcf9dbba29cd9ffa2e3b420e7
|
Provenance
The following attestation bundles were made for readables_py-0.2.4-py3-none-any.whl:
Publisher:
package-release.yml on shiroyuki/readables-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
readables_py-0.2.4-py3-none-any.whl -
Subject digest:
a67aedac72a49049ba25d04813d38b0e4427d1af871d828cef913e0652beb1b4 - Sigstore transparency entry: 1072702746
- Sigstore integration time:
-
Permalink:
shiroyuki/readables-py@0987dda712a031cc0368f03c960d71c7a9e3ad77 -
Branch / Tag:
refs/tags/0.2.4 - Owner: https://github.com/shiroyuki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package-release.yml@0987dda712a031cc0368f03c960d71c7a9e3ad77 -
Trigger Event:
release
-
Statement type: