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.3.2.tar.gz (35.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.3.2-py3-none-any.whl (39.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fundi-1.3.2.tar.gz
Algorithm Hash digest
SHA256 1aa9c03c6c82873c595e91ca6fc281f740f8be4062a7689f5818c59325535a57
MD5 c640e2a3046f2caed83f70fc0be27c2f
BLAKE2b-256 b603a1d6401a264e5b0975c0643e6c71858985612bae56a842f5b0bdd72fbcaa

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for fundi-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ae20d8b0d2282db34c98e6ae820541622692b53fe201b7d99de9d87b09ff5f40
MD5 5fe169b56047f2f28bb0f9687b6a1f32
BLAKE2b-256 d5397ba8500ab81c4017b0e0d81b9ba49fd6197d7da4bcd2b18f7def9fbba38d

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