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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fundi-1.2.2.tar.gz
Algorithm Hash digest
SHA256 e0f127832ed1d1aa126de9557c47634c75b431a8c4e9b1c4760e6de45869e434
MD5 dd9c5e9817cc3df022b5e6cc3145cb03
BLAKE2b-256 ee2f01e573bb2492d5c6121aee38ece451a7b2843cb054414b8f3c39c1bd4f06

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for fundi-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0a782e73c9c91a016cbf85e71e2c523bb5f481bb54afbe4a93fcd53032a54ccf
MD5 f27881105875e510557a3f060e11e41c
BLAKE2b-256 86f695d3c7139468710d6a4d114b87b1cdeb9041db9f13556f15c9ab7846ad36

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