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.4.tar.gz (36.4 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.4-py3-none-any.whl (40.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fundi-1.3.4.tar.gz
Algorithm Hash digest
SHA256 42a78379ad3ced4770e377330e83ee1d161b02b808f6651198cc72e0620ff5ea
MD5 569fbb8c5c55fbf18f80a0e86350d864
BLAKE2b-256 e120aa135a732708afe37658d3b6c0862df1e7f423f546a79d54d86daefcd55d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for fundi-1.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 dd6b240a79ffae8f276f9e81ac4d08bf8e17fbe29a43a5642a387c0634cabbaf
MD5 c8765b843ed28593feb9eb3b14f08ac6
BLAKE2b-256 fd324bc3497f72bdeb055f1e55a581c5b4a62fa50c2b0b25a526f65388016eb1

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