Stub file for the python-decouple package to enable static type checking
Project description
Stub File for python-decouple
This package enables static type checking for parameters retrieved from the config in the python-decouple library.
Tested with basedpyright 1.15.2
Installation
I recommend adding this package only in the development environment and not in production as it does nothing at runtime.
# using pip
pip3 install python-decople-stubs
# using poetry
poetry install python-decouple
poetry install python-decouple-stubs --group=dev
Examples
import datetime
import enum
import os
import decouple
config = decouple.config
def test_str():
os.environ["var"] = "test_string"
var = config("var")
return var # var is str
def test_int():
os.environ["var"] = "42069"
var = config("var", cast=int)
return var # var is int
def test_date():
os.environ["var"] = "3000-01-01"
var = config("var", cast=datetime.date.fromisoformat)
return var # var is date
def test_default_none():
os.environ["var"] = "test_string"
var = config("var", default=None)
return var # var is union of str and None
def test_default_int_float():
os.environ["var"] = "42"
var = config("var", default=42.69, cast=int)
return var # var is union of float and int
class ConnectionOptions(enum.Enum):
usb = "usb"
eth = "eth"
bluetooth = "bluetooth"
def test_enum():
os.environ["CONNECTION_TYPE"] = "bluetooth"
var = config("CONNECTION_TYPE", cast=ConnectionOptions)
assert ConnectionOptions.bluetooth == var
return var # var is member of Enum ConnectionOptions
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 python_decouple_stubs-3.8.0.3.tar.gz.
File metadata
- Download URL: python_decouple_stubs-3.8.0.3.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.11.2 Linux/5.15.153.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f937c2c64af0867af548da657e2f4d84aaaab4cb5d53b042c85bdca9c156cfc
|
|
| MD5 |
949661d80feaf041c960b31b45b9171c
|
|
| BLAKE2b-256 |
1038b18e9d52c7907fdb65c04059fdc5e2f2a5e53593a1e49f06e7a0a427ece8
|
File details
Details for the file python_decouple_stubs-3.8.0.3-py3-none-any.whl.
File metadata
- Download URL: python_decouple_stubs-3.8.0.3-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.11.2 Linux/5.15.153.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
248e5808519732962e9cb5349e8e44087b5acd79523fe68a0c12da593ffbc7ce
|
|
| MD5 |
e39ddaa622e9ce6a1206dec8f6505c68
|
|
| BLAKE2b-256 |
6bab5afc02203435c7852f7712d45fe746810e9072f09d063810f7d61ca1c1af
|