Skip to main content

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

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-decople-stubs

# using poetry
poetry install python-decople
poetry install python-decople-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.2.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.2-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_decouple_stubs-3.8.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 5cb3b6d142f9dbe1a6b62ad1294471ca4448fba8c8cbb06f4b59275709b1e535
MD5 11eeaf33ec158a310e38934db580c12f
BLAKE2b-256 b75781de0a7100e75adb7c88f52619707f3854a81db09b7e8ce49d89448103ec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_decouple_stubs-3.8.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 33af96b6c814e1ed6c2c9fa52110aa161617ea504ea05436b36ef30fd580c5c3
MD5 9a862168e71e0eb20deb69b51e117e79
BLAKE2b-256 3ed7f3d0803d2986d6358fc76951409235a6ef6f745fac6b9e7842a0aba570dd

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