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.1.tar.gz (29.8 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.1-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fundi-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f4861dfece25b283a7f1a945ae19254b7fda9312c3204df1205b8fcda6ce0dfc
MD5 9ee45f7fd275f86ffa21291b51e8c4cb
BLAKE2b-256 388a86ed6b9576b6a5690d16365bde6afaa3ccdaafb0486aed9912bd00ef4bb8

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for fundi-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 361aba5739e5dea082d61a990e383e5540c84a9e53a7ecd5153776c0a3e4d313
MD5 d60075ecdb52ec834c3981bff7143f78
BLAKE2b-256 8d605c2bf18cf6bb58f44e4eb093b78f5bc76befef882267a582bca4d8aed645

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