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.1.1.tar.gz (31.1 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.1.1-py3-none-any.whl (33.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fundi-1.1.1.tar.gz
Algorithm Hash digest
SHA256 7de6dbf26e2870491b69025e1c32b44bf3884ba3c09d04f9d4075c1fbc834675
MD5 95c4cd61c74f973f6fc75db89a32f347
BLAKE2b-256 d83b95eaa6de39c6eadf59899c477f9725edb4e9ab4dd8699bada9f2a8acb3fc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for fundi-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9a8c539935247caf70abc9209c6e706087ad0eca1ad81b1d9d7b3bc044d87874
MD5 6ec87e41c9d89e4fe1d898bbcc1c287f
BLAKE2b-256 701780e04dbf31bbefe8f53943f6756e3e7eb58cd2bdae54e6335b3b241bf8ac

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