Bug: NameError: name 'Response' is not defined when starting server
Describe the bug
Running apiup crashes after printing the route list with a NameError when Litestar tries to inspect the handler signature.
Steps to reproduce
Error
NameError: name 'Response' is not defined
Full traceback originates in litestar/utils/signature.py → get_type_hints() → annotationlib.py.
Root cause
from __future__ import annotations makes Python lazy-evaluate all annotations as strings. When Litestar calls get_type_hints() at handler registration time, it resolves -> Response against the global scope — but Response was only imported inside the build_mock_app function body, making it invisible at that point.
Fix
- Move
from litestar.response import Response as LitestarResponse to module level
- Change handler return type from
-> Response to -> Any to avoid Litestar signature introspection
Environment
- Python 3.14.3
- apiup 0.1.0
- litestar latest
- Fedora (Silverblue)
Labels
bug good first issue
Bug:
NameError: name 'Response' is not definedwhen starting serverDescribe the bug
Running
apiupcrashes after printing the route list with aNameErrorwhen Litestar tries to inspect the handler signature.Steps to reproduce
Error
Full traceback originates in
litestar/utils/signature.py→get_type_hints()→annotationlib.py.Root cause
from __future__ import annotationsmakes Python lazy-evaluate all annotations as strings. When Litestar callsget_type_hints()at handler registration time, it resolves-> Responseagainst the global scope — butResponsewas only imported inside thebuild_mock_appfunction body, making it invisible at that point.Fix
from litestar.response import Response as LitestarResponseto module level-> Responseto-> Anyto avoid Litestar signature introspectionEnvironment
Labels
buggood first issue