Handy import wrappers to simplify optional dependency management
Project description
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file import-wrappers-0.0.2.tar.gz
.
File metadata
- Download URL: import-wrappers-0.0.2.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f0ae90a47fff95278626ec20a8cc6e2f1067475f1c637b7515317a1ec15c5cf |
|
MD5 | 4e6eafcc90d2f6de44c1376fe674d5fd |
|
BLAKE2b-256 | fccea435d3207dfc43c355fc805a80c408147da6767b4266f8e22d616361aa38 |
File details
Details for the file import_wrappers-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: import_wrappers-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fc0785f73bf0b20bea7d1325f84699e4e3c73fd9489eb4bdae7b7a7d551dda9 |
|
MD5 | 82742f76f0820210df886dfdf56d7da4 |
|
BLAKE2b-256 | ca776ee1d37c745e12557c0539bca0424a3b06629067f171bce32acd6bc6fd30 |