Skip to content

ImportError: cannot import name 'get_flat_dependant' from 'fastapi.dependencies.utils' with FastAPI >= 0.140.0 #103

Description

@JoKnopp

Summary

fastapi-jsonrpc 3.5.0 fails to import with FastAPI 0.140.0+ because it imports get_flat_dependant from fastapi.dependencies.utils, which was removed in FastAPI 0.140.7.

Environment

fastapi-jsonrpc 3.5.0
fastapi (broken) 0.140.13
fastapi (last working) 0.139.2
starlette 1.3.1
pydantic 2.13.x
Python >=3.11

Steps to reproduce

uv run --with 'fastapi-jsonrpc==3.5.0,fastapi>=0.140.0' python -c 'import fastapi_jsonrpc'

or using pip:

  pip install 'fastapi-jsonrpc==3.5.0' 'fastapi>=0.140.0'
  python -c "import fastapi_jsonrpc"

Expected behavior

import fastapi_jsonrpc succeeds with the latest FastAPI release.

Actual behavior

Import fails immediately:

Traceback (most recent call last):
File "", line 1, in
File ".../fastapi_jsonrpc/init.py", line 24, in
from fastapi.dependencies.utils import solve_dependencies, get_dependant, get_flat_dependant,
ImportError: cannot import name 'get_flat_dependant' from 'fastapi.dependencies.utils' (.../fastapi/dependencies/utils.py)

Workaround

Pin FastAPI below 0.140 until a fixed release is available:

fastapi = ">=0.135,<0.140"

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions