Skip to main content

Dependency injection library

Project description

FunDI logo

# FunDI

Solution for problem no one had before

Fun stays for function(or for fun if you wish) and DI for Dependency Injection

This library provides fast(to write!) and convenient(to use!) Dependency Injection for functional programming on python.

Why?

This library was inspired by FastAPI's dependency injection. The reasons for its existence are simple:

  • A standalone dependency injection library. DI shouldn't be tied to a specific framework.
  • It simplifies code writing. Dependency injection reduces boilerplate and improves maintainability.
  • Lack of DI libraries for functional programming in Python. Or maybe I just didn't want to find one :3

No more words, let's try!

from contextlib import ExitStack

from fundi import scan, from_, inject


def require_user():
    return "Alice"


def greet(user: str = from_(require_user)):
    print(f"Hello, {user}!")


with ExitStack() as stack:
    inject({}, scan(greet), stack)

See the documentation to get more examples: https://fundi.readthedocs.io/en/latest/

Project details


Download files

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

Source Distribution

fundi-1.1.6.tar.gz (32.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fundi-1.1.6-py3-none-any.whl (35.7 kB view details)

Uploaded Python 3

File details

Details for the file fundi-1.1.6.tar.gz.

File metadata

  • Download URL: fundi-1.1.6.tar.gz
  • Upload date:
  • Size: 32.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.9

File hashes

Hashes for fundi-1.1.6.tar.gz
Algorithm Hash digest
SHA256 5c63649f1f8b856135da01f02053aa16ae8544269734709ebbbeee52d998cc4d
MD5 0274a8ef45884d1b12625aff37712d3c
BLAKE2b-256 88f2e532083577afb27b70cd92927e2776387eb4d2dac25ef15f15e59696806b

See more details on using hashes here.

File details

Details for the file fundi-1.1.6-py3-none-any.whl.

File metadata

  • Download URL: fundi-1.1.6-py3-none-any.whl
  • Upload date:
  • Size: 35.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.9

File hashes

Hashes for fundi-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f40e9f8be7f16cc5b3666569e61e2689dae17e45924405b3f65c541ecf4567cc
MD5 f66a77cc4007adef31d714f296a4e717
BLAKE2b-256 460ad2162b17c3f00ace76c83d1ab2ca443daf90692b56a9e91a194f4830f081

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page