Skip to main content

Unavailable Object

A placeholder object for optional dependencies.

Usage

from unavailable_object import UnavailableObject

try:
    import optional_module
except ImportError:
        optional_module = UnavailableObject("optional_module")

Type Checking

To not disturb the type checker, the alternative definition of optional_object should be guarded by if not TYPE_CHECKING and type annotations put in quotes:

from typing import TYPE_CHECKING
from unavailable_object import UnavailableObject

try:
    import optional_module
except ImportError:
    if not TYPE_CHECKING:
        optional_module = UnavailableObject("optional_module")

def foo(arg: "optional_module.SomeType") -> None:
    pass

Metadata

Release files for unavailable-object 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unavailable-object 0.0.2
File Size Uploaded
unavailable-object-0.0.2.tar.gz 18.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for unavailable-object 0.0.2
File Interpreter ABI Platform
unavailable_object-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 26.0 kB

Release files / unavailable-object-0.0.2.tar.gz

Download URL unavailable-object-0.0.2.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d1d4fab3f90950a9f88f65a3e93144823d59858daff9d46e1940e1d0fbde0932
BLAKE2b-256 checksum
How to use checksums
7aace0e186cf8d829f2a7006545abd9185eb57a7542066a788bf4e6899cb2066
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release files / unavailable_object-0.0.2-py3-none-any.whl

Download URL unavailable_object-0.0.2-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87f466ea3cff25080e2ecbe562e70596a5fb8e73ca499c512c0b7c4b38d8ef1e
BLAKE2b-256 checksum
How to use checksums
0c62e9152b7963c11c19bb0ed917b4ba4c0e031176ba99a025b13d60aea9b37d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page