Skip to content

Fix TypeError on Python 3.14 when annotations reference TYPE_CHECKING… - #327

Open
philsong4-ai wants to merge 1 commit into
lundberg:masterfrom
philsong4-ai:fix/322-type-checking-annotations
Open

Fix TypeError on Python 3.14 when annotations reference TYPE_CHECKING…#327
philsong4-ai wants to merge 1 commit into
lundberg:masterfrom
philsong4-ai:fix/322-type-checking-annotations

Conversation

@philsong4-ai

Copy link
Copy Markdown

…-only names (#322)

inspect.getfullargspec forces evaluation of a callable's annotations, which under PEP 649 (Python 3.14+) raises TypeError: unsupported callable for callables that reference names only available under TYPE_CHECKING (e.g. typing a SQLAlchemy AsyncSession fixture without importing it at runtime).

respx only needs parameter names, so when getfullargspec fails we fall back to inspect.signature with annotation_format set to ForwardRef on 3.14+, degrading unresolved names to ForwardRef placeholders instead of raising.

…-only names (lundberg#322)

inspect.getfullargspec forces evaluation of a callable's annotations, which
under PEP 649 (Python 3.14+) raises ``TypeError: unsupported callable`` for
callables that reference names only available under TYPE_CHECKING (e.g. typing a
SQLAlchemy AsyncSession fixture without importing it at runtime).

respx only needs parameter names, so when getfullargspec fails we fall back to
inspect.signature with annotation_format set to ForwardRef on 3.14+, degrading
unresolved names to ForwardRef placeholders instead of raising.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant