Skip to main content

Creates a class used to query environmental variables with typehinting a conversion to basic Python types.

Project description

EnvProxy

EnvProxy provides a class used to query environmental variables with typehinting a conversion to basic Python types. You can query your environment easily and keep your typehinting.

Installation

Using pip:

pip install env-proxy

Using poetry:

poetry add env-proxy

Example

# Import EnvProxy
from env_proxy import EnvProxy

# Basic examples
## Environment variable "DATABASE_HOST"
database_host = EnvProxy.get_str("database-host")

## If you want the function to fail if the value does not exist, use methods with `_strict` suffix
database_nonsene = EnvProxy.get_str_strict("database-nonsense")
### ValueError: No value for key DATABASE_NONSENSE in environment

## Specify default for the (non-zero) variable "DATABASE_PORT"
database_port = EnvProxy.get_int("database-port") or 5432

# Specify custom prefix
class MyProxy(EnvProxy):
    env_prefix: Optional[str] = "MYAPP"
## Now all variables are expected to be prefixed with MYAPP_
database_host = EnvProxy.get_str("database-host")
### Searches for MYAPP_DATABASE_HOST variable

Documentation

See docs

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

env_proxy-0.1.3.tar.gz (2.0 kB view details)

Uploaded Source

Built Distribution

env_proxy-0.1.3-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file env_proxy-0.1.3.tar.gz.

File metadata

  • Download URL: env_proxy-0.1.3.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/23.0.0

File hashes

Hashes for env_proxy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 a978cbc671da36f905392739a9b2e1da134e9454d5d2725faffa78b2c03ebe64
MD5 f023023f7927e24cf65e285ab8036c6e
BLAKE2b-256 c4fe61b9de2a2c79de59b0bca8c21fdb9641d01fbfccf78a11732ce6a8390dc4

See more details on using hashes here.

File details

Details for the file env_proxy-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: env_proxy-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 2.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/23.0.0

File hashes

Hashes for env_proxy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d2157b65639fd13be7afbca51e84062476699fdf97b80ce7c973b1da325da4cc
MD5 66a6772bb411d13d0ea9f63a1bcc251a
BLAKE2b-256 47c00ad808af676becae2466cd1f4c2b4674e667b0c849fcb7a3fed9a4abd1d7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page