Skip to content

ivan-telepop/telepop-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

telepop-env

Tinyenv zero-dependency environment variable loader for Python.
Reads .env + os.environ, supports type casting, validation, and .env.example generation.


Features:

Zero dependencies

Automatic type casting (bool, int, float, str)

Required variable check

.env.example generation from used variables


Install

pip install telepop-env setuptools wheel

Usage:

from telepop_env import env

DEBUG = env.bool("DEBUG", default=False)
DB_PORT = env.int("DB_PORT", required=True)
DB_URL = env.str("DB_URL", default="sqlite:///:memory:")

# these will be added to project environment variables
print(DEBUG, DB_PORT, DB_URL)

How to generate .env with env.generate_example()

from telepop_env import env

# define variables inside your app
DEBUG=env.bool('DEBUG',default=False,required=True)
DB_PORT=env.int('DB_PORT',default=5432)
DB_URL = env.str("DB_URL", default="sqlite:///:memory:")

# then call function
env.generate_example()

It will generate .env.example in your project root with defined variables names. I guess it useful while you need to create new .env with empty values. Rename it and use !

DEBUG=
DB_PORT=
DB_URL=

Pypi page:

https://pypi.org/project/telepop-env/

About

**Tinyenv zero-dependency environment variable loader** for Python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages