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.2.3.tar.gz (34.5 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.2.3-py3-none-any.whl (38.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fundi-1.2.3.tar.gz
  • Upload date:
  • Size: 34.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.2

File hashes

Hashes for fundi-1.2.3.tar.gz
Algorithm Hash digest
SHA256 cfd195f503b4c5d600547c7ea1eef9c6ecfce164f258b8b7a179e4b01f3bc163
MD5 eba01549500838386cf043d9373625cc
BLAKE2b-256 e5296f23e1bde30c7a8d98f4673e6e4dda3576d2a0ed88a76d2afb97bf55fe17

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fundi-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 38.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.2

File hashes

Hashes for fundi-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 304560d41e3750e254d85d2503bdd1563d66374be124d2fc4fd42111b7f3d346
MD5 02d1f51ad8f3fc114096838a04a41856
BLAKE2b-256 e1ceec2bccc56eae9ad0b08d90361365fec45e46964e4e1c4c5f6e6ab8091ab2

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