Hetman Kit Environment is a developer-centric environment variable manager. It leverages the Hetman Pipeline engine to treat environment variables not just as strings, but as strictly validated and transformed data structures.
Project description
Hetman Kit Environment is a developer-centric environment variable manager. It leverages the Hetman Pipeline engine to treat environment variables not just as strings, but as strictly validated and transformed data structures.
Installation
pip install hetman-kit-env
Why use this?
Standard os.environ.get returns strings and provides no validation. Hetman Kit Environment allows you to:
- Validate length, patterns, and types immediately.
- Transform values (lowercase, strip, cast) during retrieval.
- Parse JSON structures stored in environment strings automatically.
- Enforce existence for missing variables.
Usage Example
from hetman_kit_env import EnvironmentVariable
from pipeline import Condition, Match, Transform
# Set the path for your .env file
EnvironmentVariable.dotenv_path = ".env"
# Define a validated environment variable
# This will raise an exception if the key is missing or validation fails
SECRET_KEY = EnvironmentVariable[str](
name="SECRET_KEY",
type=str,
conditions={
Condition.ExactLength: 32
},
matches={
Match.Text.Letters: None
},
transform={
Transform.Lowercase: None
}
)
# Access the processed value
print(SECRET_KEY.get)
# You can call to get the raw value (Clean variable)
API_PORT: int = EnvironmentVariable[int](name="API_PORT", type=int)()
Pythonic Access Patterns
You don't have to manually call .get every time. The EnvironmentVariable instance implements magic methods to make your code cleaner:
-
Direct Comparison: Use
==to compare the variable directly with a value.if SECRET_KEY == "expected_hash_value": ...
-
Boolean Logic: Use it directly in
ifstatements to check if the value is truthy.DEBUG_MODE = EnvironmentVariable[bool](name="DEBUG", optional=True) if DEBUG_MODE: print("Debug is enabled")
-
String Conversion: Use it directly in f-strings or
print().print(f"API_URL: {API_URL}")
-
Callable shorthand: Call the object like a function to get the value.
current_key = SECRET_KEY()
Core Features
- Strict Typing: Use Python generics
EnvironmentVariable[T]for better IDE support and type safety. - JSON Ready: Built-in
json.loadssupport for complex environment configurations. - Pipeline Integration: Full access to the Pipeline execution flow (Type Check -> Setup -> Conditions -> Matches -> Transformations).
- Singleton .env Loading: The
.envfile is loaded once and shared across all instances.
Documentation
This package uses the Hetman Pipeline logic for its core processing. To learn more about available conditions, matches, and transformations, visit Official Documentation
Project details
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 hetman_kit_env-0.2.1.tar.gz.
File metadata
- Download URL: hetman_kit_env-0.2.1.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22f4b26dd6f6e29b30a237938848a92a1561019acbd711947d8c70a6077daca7
|
|
| MD5 |
a31a645b57c5db8a2f8e476b50d1ba0f
|
|
| BLAKE2b-256 |
a60281191dd607eb26f25d00b16d6c14a82a9ddcefd8a75cdb5435056c4f67cb
|
Provenance
The following attestation bundles were made for hetman_kit_env-0.2.1.tar.gz:
Publisher:
python-publish.yml on hetman-app/hetman-kit-env
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hetman_kit_env-0.2.1.tar.gz -
Subject digest:
22f4b26dd6f6e29b30a237938848a92a1561019acbd711947d8c70a6077daca7 - Sigstore transparency entry: 815487606
- Sigstore integration time:
-
Permalink:
hetman-app/hetman-kit-env@044e233abf64e9fa03b60ccd7c5ae1771ceef1e0 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/hetman-app
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@044e233abf64e9fa03b60ccd7c5ae1771ceef1e0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file hetman_kit_env-0.2.1-py3-none-any.whl.
File metadata
- Download URL: hetman_kit_env-0.2.1-py3-none-any.whl
- Upload date:
- Size: 9.7 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 |
781007e1b2b2511ac5b5808436202b55a29639e81eda6a7cff10ac3752baa6f3
|
|
| MD5 |
7190b0367abb42f2cfc788943adc6806
|
|
| BLAKE2b-256 |
6958e758000cb41c369e7c0e0a8be7c56e5d7c8adb047f9f3cf807ac860df051
|
Provenance
The following attestation bundles were made for hetman_kit_env-0.2.1-py3-none-any.whl:
Publisher:
python-publish.yml on hetman-app/hetman-kit-env
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hetman_kit_env-0.2.1-py3-none-any.whl -
Subject digest:
781007e1b2b2511ac5b5808436202b55a29639e81eda6a7cff10ac3752baa6f3 - Sigstore transparency entry: 815487614
- Sigstore integration time:
-
Permalink:
hetman-app/hetman-kit-env@044e233abf64e9fa03b60ccd7c5ae1771ceef1e0 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/hetman-app
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@044e233abf64e9fa03b60ccd7c5ae1771ceef1e0 -
Trigger Event:
release
-
Statement type: