Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

a small package for enforcing package requirements at the class- or function-level

Project description

version number: “0.1.0”
author: Max Lee

Build Status Coverage Status

Overview

force-dependencies is a small package for enforcing package requirements at the class- or function-level.

Simply use:

from force_deps import requires, requires_any, requires_all

@requires("sqlalchemy")
class SQLHandler(object):
    def __init__(self):
        pass

db = SQLHandler()
Traceback (most recent call last):
    ...
ImportError: You must import `sqlalchemy` in order to run `SQLHandler`

to require users to have a package installed in order to use your class or function,

@requires_any(["sqlalchemy", "sqlite3"])
...

to require that users have at least one of a number of packages installed, or

@requires_all(["sqlalchemy", "pandas"])
...

to require that users have all of a number of packages installed in order to use a class or function.

Finally, you can combine the decorators together in pretty much any way you please:

@requires_any(["sqlalchemy", "sqlite3"])
@requires("pandas")
...

Installation / Usage

This library requires Python>=3.5. You should be able to extend its compatibility by removing the dependencies
on Python’s typing libraries.

To install use pip:

$ pip install force_deps

Or clone the repo:

$ git clone https://github.com/maxblee/force_deps.git
$ python setup.py install

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for force-deps, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size force_deps-0.1.0-py2.py3-none-any.whl (4.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size force_deps-0.1.0.tar.gz (3.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page