Skip to content

Commit 6eeb37f

Browse files
committed
docs: note @cython.annotation_typing(False) for FastAPI views/deps
1 parent 945ddbd commit 6eeb37f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

docs/wiring.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,27 @@ extensions for a FastAPI / dependency-injector codebase:
688688
},
689689
)
690690
691+
FastAPI views and dependencies that rely on parameter defaults as
692+
markers (``param: str = Header(...)``, ``svc: Service = Depends(...)``,
693+
``Provide[Container.x]``) need Cython's C-level annotation typing
694+
disabled. The default in Cython 3.x is ``annotation_typing=True``, which
695+
generates ``isinstance`` checks against the annotated types and rejects
696+
the marker objects at call time. Opt out per-function:
697+
698+
.. code-block:: python
699+
700+
import cython
701+
702+
@cython.annotation_typing(False)
703+
async def list_users(
704+
svc: UserService = Depends(Provide[Container.user_service]),
705+
) -> list[User]:
706+
return await svc.list()
707+
708+
Apply the decorator to every FastAPI view or dependency callable that
709+
takes a marker-style default. Module-level ``annotation_typing=False``
710+
works too if the whole module is FastAPI-bound.
711+
691712
Few notes on performance
692713
------------------------
693714

0 commit comments

Comments
 (0)