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.1.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.1-py3-none-any.whl (39.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fundi-1.3.1.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.1.tar.gz
Algorithm Hash digest
SHA256 e3b2e2cc19af2e21a7b8953788f9fe0cf56ddcba97f2f733f1f499ffa3aa71e4
MD5 cee02103e5ea9a9ed66f4691613221e2
BLAKE2b-256 2d7d439a85e2f59d64a1952ce29d743f721850dcb691a8ec60e473c287ef014b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fundi-1.3.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b628c7f173dd3d9600db80157363fa6a0fce077950966f0e0b14f136017b45d6
MD5 b2ce0650ecdfce26e42fa7d7cf2e8b7e
BLAKE2b-256 88fabbcfcf268e19f9fca34351f851d6bf62a809d55babca16e49f9b59f8d8c0

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