Metadata-Version: 2.1
Name: import-wrappers
Version: 0.0.2
Summary: Handy import wrappers to simplify optional dependency management
Author-email: Elisha Yadgaran <ElishaY@alum.mit.edu>
License: MIT License
        
        Copyright (c) 2023 Elisha Yadgaran
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: isort ; extra == 'dev'
Requires-Dist: black ; extra == 'dev'
Requires-Dist: flake8 ; extra == 'dev'
Requires-Dist: mypy ; extra == 'dev'

[![PyPI version](https://badge.fury.io/py/import-wrappers.svg)](https://badge.fury.io/py/import-wrappers)
![PyPI pyversions](https://img.shields.io/pypi/pyversions/import-wrappers.svg)
[![Coverage Status](https://coveralls.io/repos/github/eyadgaran/import-wrappers/badge.svg)](https://coveralls.io/github/eyadgaran/import-wrappers)
![Build Status](https://github.com/eyadgaran/import-wrappers/actions/workflows/test.yml/badge.svg?branch=main)

# 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
```python
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
```python
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)
```
