Skip to main content

fastapi-pypendency

Pypendency integration with FastAPI.

Based on

Installation

pip install fastapi-pypendency

Usage

Configure your FastAPI app with the Pypendency class:

import os
from fastapi import FastAPI
from fastapi_pypendency import Pypendency


app = FastAPI()

Pypendency(
    app,
    "_dependency_injection",
    [os.path.dirname(os.path.abspath(__file__))],  # ["src"],
)

A sample controller:

# get_user_controller.py
class GetUserController:
    def get(self) -> dict:
        return {"user": "John Doe"}
# _dependency_injection/get_user_controller.yaml
GetUserController:
  fqn: get_user_controller.GetUserController

On your router:

from fastapi import APIRouter
from fastapi import Request
from fastapi_pypendency import ContainerBuilder
from fastapi_pypendency import get_container
from get_user_controller import GetUserController


router = APIRouter(
    prefix="/user",
    tags=["user"],
    dependencies=[],
    responses={404: {"description": "Not found"}},
)

@router.get("/")
def get_user(request: Request):
    container: ContainerBuilder = get_container(request)
    controller: GetUserController = container.get("GetUserController")
    return controller.get()

Metadata

Release files for fastapi-pypendency 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastapi-pypendency 0.1.3
File Size Uploaded
fastapi_pypendency-0.1.3.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-pypendency 0.1.3
File Interpreter ABI Platform
fastapi_pypendency-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 7.0 kB

Release files / fastapi_pypendency-0.1.3.tar.gz

Download URL fastapi_pypendency-0.1.3.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ffabb3af0ed64b825cb2785f5d02bbab118e6044ac1f0d7ac01de45235d4340e
BLAKE2b-256 checksum
How to use checksums
dfb6744f43836af18afa12ef4391683c6fe9c16f509b284eadd014cbd819b442
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / fastapi_pypendency-0.1.3-py3-none-any.whl

Download URL fastapi_pypendency-0.1.3-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c2fb5962d086e396a5f5e200c46d71bb1a145c62b62b07b3ae34a1314f78bb1c
BLAKE2b-256 checksum
How to use checksums
2b8ced8758ade28b92bb1f09a0360e68be3f25d729ce8d05e51b9c89d8e8be0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page