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.3.tar.gz (35.7 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.3-py3-none-any.whl (39.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fundi-1.3.3.tar.gz
Algorithm Hash digest
SHA256 1e4b206a611fb1732790a4a1f910c7d0af200fbe505952bd6416a4f12602217e
MD5 2910a6c00ebecc8dd79b5184ff2eeeea
BLAKE2b-256 4e6a072b990ac192796eb22e0da977290dbdb3692ae0794663adb05818ab937e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for fundi-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f5dcbed85c8c64872bf94c62d4d203c00b1eaf9c7c7b15a8e6e7cb88891cc756
MD5 324891da28edb18d46693dcafd3fd2c2
BLAKE2b-256 a73f92bbef0a0e539679e5a505621eab18504b6ac19823f948deb59f008ca1dc

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