Skip to main content

Dependency injection library

Project description

# 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.0.0.tar.gz (29.3 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.0.0-py3-none-any.whl (31.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fundi-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b374b054928715418e88d0dc2512914aa5fe2fae9c6a84358303c3275ae52470
MD5 04382b4cb98fdead2c396a0292616376
BLAKE2b-256 4fc4dc4c146431d40fbfccf3eb5740c9c4b43db9f486d29bcf02ec8ed5ec9501

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for fundi-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f613f2d12ead5b554fd0f34997b1c52a1cfd65556457fad936705617c7449a6d
MD5 cab38f5073e4b5915c1a7f7478cafb6c
BLAKE2b-256 3c9dd6d23bc9f26fbde59709f22e261fabd08b84518458b287abfa925b459e5f

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