Skip to main content

Dependency injection framework designed with Python in mind.

Project description!-1EAEDB.svg

Picobox is opinionated dependency injection framework designed to be clean, pragmatic and with Python in mind. No complex graphs, no implicit injections, no type bindings – just picoboxes, and explicit demands!


Because we usually want to decouple our code and Python lack of clean and pragmatic solutions (even third parties).


  • Support both values and factories.
  • Support scopes (e.g. singleton, threadlocal, contextvars).
  • Push boxes on stack, and use the top one to access values.
  • Thread-safe.
  • Lightweight (~213 LOC including scopes).
  • Zero dependencies (on python3).
  • Pure Python.



$ [sudo] python -m pip install picobox

and then

import picobox
import requests

@picobox.pass_('requests', as_='session')
def get_resource(uri, session, conf):
    return session.get(conf['base_uri'] + uri)

box = picobox.Box()
box.put('conf', {'base_uri': ''})
box.put('requests', factory=requests.Session, scope=picobox.threadlocal)

with picobox.push(box):
    get_resource('/resource', requests.Session(), {})
    get_resource('/resource', requests.Session())

Download files

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

Files for picobox, version 2.2.0
Filename, size File type Python version Upload date Hashes
Filename, size picobox-2.2.0-py2.py3-none-any.whl (12.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size picobox-2.2.0.tar.gz (30.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page