Skip to main content

No project description provided

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.1.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.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_decouple_stubs-3.8.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 d876d852ff758fab2b0bbad8194591890e217718b67c8516b997f18419844345
MD5 75d513c41da76d0ff7633b01c65e8c59
BLAKE2b-256 8ed0422634b00b47d5638e402a033ddc99e851e43e0ee3b51ba20788961b94ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_decouple_stubs-3.8.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dee35f4d041a1946666353e1d6025ab69e6115b708eddc2dbd6c3e1c88f16cc8
MD5 b02f776b670afe918dca6f4bf0e3484f
BLAKE2b-256 ec1e878f241129adfd46cd3ff10c07d157683eee29120b5887107bf39a885788

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