Skip to main content
# pyhooker

Lightweight and easy-to-use python dependency injection library

Pyhooker is ready to use for Python >=2.7 and >=3.2

[![Build Status](https://travis-ci.org/sighalt/pyhooker.svg?branch=master)](https://travis-ci.org/sighalt/pyhooker)


## Installation

```
pip install git+https://github.com/sighalt/pyhooker.git
```

## Usage

```python
import pyhooker


# wheel.py

class IWheel(object):
pass


class MichelinWheel(IWheel):
pass

# engine.py

class IEngine(object):
pass


class OttoEngine(IEngine):
pass


# car.py

class ICar(object):
pass


class Car(ICar):

@pyhooker.inject_params(engine=IEngine, wheel_type=IWheel)
def __init__(self, engine, wheel_type):
self.engine = engine
self.wheel_type = wheel_type

# driver.py

class Driver(object):

@pyhooker.inject_params(car=ICar)
def __init__(self, car):
self.car = car

# __init__.py

pyhooker.register(ICar, Car)
pyhooker.register(IEngine, OttoEngine)
pyhooker.register(IWheel, MichelinWheel)

driver = Driver()

print("The driver is %s\n... with its car %s\n... and engine %s\n... and wheel type %s" % (driver,
driver.car,
driver.car.engine,
driver.car.wheel_type))
```

Metadata

Release files for pyhooker 1.0.1

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

Source distribution (sdist)

Source distribution for pyhooker 1.0.1
File Size Uploaded Provenance
pyhooker-1.0.1.tar.gz 25.7 kB Without provenance Details

Release files / pyhooker-1.0.1.tar.gz

Download URL pyhooker-1.0.1.tar.gz
Size 25.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d2e734197d9bcfe0610c1c17b8144aabf7486da64ff1ecc4244ad699a71afa85
BLAKE2b-256 checksum
How to use checksums
8ba569a58844c2e9225ee73b50f8d983039de4f31dca5cf9024bae74bbf83cbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyhooker 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file No provenance

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