Skip to main content

PyPI version PyPI pyversions Coverage Status Build Status

Import Wrappers

A simple set of utilities to make working with various import patterns easy.

Installation

pip install import-wrappers

Optional Dependencies

The original motivation for this library was the repetitive utilities I found myself authoring to hack around supporting optional dependencies in other projects. Optional dependencies are a common pattern where the core of a library does not depend on a dependency but some functionality may require it. Most users may never interact with the code that requires the optional dependency but without proper handling will still be required to install them and by extension inherit the overhead of managing dependency versions and conflicts.

Usage

Wrapping Optional Dependencies

Typical import pattern - this fails on import whether or not the dependency is used

from optional_dependency import SomeUnusedClass


def some_function_that_isnt_needed(*args, **kwargs):
    return SomeUnusedClass().some_method(*args, **kwargs)

Same functionality using import wrappers - only raise an error on USE, not import

from import_wrappers.optional_dependencies import OptionalDependencyWrapper

SomeUnusedClass = OptionalDependencyWrapper('optional_dependency', 'SomeUnusedClass')

def some_function_that_isnt_needed(*args, **kwargs):
    return SomeUnusedClass().some_method(*args, **kwargs)

Metadata

Release files for import-wrappers 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 import-wrappers 0.0.2
File Size Uploaded
import-wrappers-0.0.2.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for import-wrappers 0.0.2
File Interpreter ABI Platform
import_wrappers-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 11.2 kB

Release files / import-wrappers-0.0.2.tar.gz

Download URL import-wrappers-0.0.2.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3f0ae90a47fff95278626ec20a8cc6e2f1067475f1c637b7515317a1ec15c5cf
BLAKE2b-256 checksum
How to use checksums
fccea435d3207dfc43c355fc805a80c408147da6767b4266f8e22d616361aa38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.16

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

Download URL import_wrappers-0.0.2-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5fc0785f73bf0b20bea7d1325f84699e4e3c73fd9489eb4bdae7b7a7d551dda9
BLAKE2b-256 checksum
How to use checksums
ca776ee1d37c745e12557c0539bca0424a3b06629067f171bce32acd6bc6fd30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.16

Release history Release notifications | RSS feed

This release

0.0.2 This release

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