Skip to main content

Stub file for the python-decouple package to enable static type checking

Project description

Stub File for python-decouple

PyPI - Version

This package enables static type checking for parameters retrieved from the config in the python-decouple library.

Tested with basedpyright 1.15.2

Github

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-decouple-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

python_decouple_stubs-3.8.0.4.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_decouple_stubs-3.8.0.4-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file python_decouple_stubs-3.8.0.4.tar.gz.

File metadata

  • Download URL: python_decouple_stubs-3.8.0.4.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

Hashes for python_decouple_stubs-3.8.0.4.tar.gz
Algorithm Hash digest
SHA256 9926133d6ee609248a44e5c0ebc9f9391cbe221c8acb5d34980c1e70ac4007d0
MD5 c406cd882fc6e0fa6147f22af1d7178d
BLAKE2b-256 68270d58fdf76d088ee21a7605ea6a48cd75d75400ed9322e6e3f1e933f8dd26

See more details on using hashes here.

File details

Details for the file python_decouple_stubs-3.8.0.4-py3-none-any.whl.

File metadata

  • Download URL: python_decouple_stubs-3.8.0.4-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

Hashes for python_decouple_stubs-3.8.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2c1ea62305077651637b7e310427aca6d2627d214c438663a5fb3bd4b701b042
MD5 2d3850ee0799f7b5e6af38dfedad179b
BLAKE2b-256 ddeadbe2ad5e2c935ebdb4398971348a64f261e1092c1dd307b376d0d328f842

See more details on using hashes here.

Supported by

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