Skip to main content

Chain FastAPI dependencies without unused Depends!

Project description

fastapi-di-chain

Chain FastAPI dependencies without unused Depends!

Overview

fastapi-di-chain provides a utility to chain FastAPI dependencies in a way that avoids unused Depends parameters, making your dependency injection cleaner, more maintainable and easier to integrade.

Installation

pip install fastapi-di-chain

Usage

Suppose you have several dependencies that you want to chain together:

from fastapi import FastAPI, Depends
from fastapi_di_chain import DependsChain

app = FastAPI()

def my_rate_limiting_dependency() -> None:
    # e.g. checks rate limiting
    pass

def my_authentication_dependency() -> None:
    # e.g. checks that user is authenticated to do a request
    pass

dependency_chain = DependsChain | my_rate_limiting_dependency | my_authentication_dependency

@app.get("/profile", dependencies=[dependency_chain])
def profile() -> dict:
    return {"user": 123}

License

fastapi-di-chain is distributed under the terms of the MIT license. Please see License.md for more information.

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

fastapi_di_chain-0.0.6.tar.gz (46.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_di_chain-0.0.6-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_di_chain-0.0.6.tar.gz.

File metadata

  • Download URL: fastapi_di_chain-0.0.6.tar.gz
  • Upload date:
  • Size: 46.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fastapi_di_chain-0.0.6.tar.gz
Algorithm Hash digest
SHA256 9ad7953f1ae0ba63db4e080d7192185fa1ffe0c6e4a5b4e945f7566cca4c1149
MD5 0cf66faab8a1f7dbb95ec5d11da0c3c4
BLAKE2b-256 adc95d2c61a4cc9e6dc3115f8d98c866a46ed2991337fe627835f84075e1b2e8

See more details on using hashes here.

File details

Details for the file fastapi_di_chain-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: fastapi_di_chain-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fastapi_di_chain-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f988e2aa530e72788fbd760187610191d2e713fe77e27bfb3e12dd87c0fd8a76
MD5 82a85a6f87d9e2cd7bf3f5ed84d0fa10
BLAKE2b-256 d21d4aefeaac9a8ab9b6bd1bc6115626e9cdba449cb8b7d9a0de2b688d11ce65

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