Last active
February 20, 2026 22:18
-
-
Save Gounlaf/a4d52d750871960c90e3856b526fcb00 to your computer and use it in GitHub Desktop.
MRE Wireup Issue 106
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /home/linuxbrew/.linuxbrew/bin/uv run /home/gounlaf/code/mre-wireup-issue/.venv/bin/python /home/gounlaf/code/mre-wireup-issue/main.py | |
| INFO: Started server process [794504] | |
| INFO: Waiting for application startup. | |
| INFO: Application startup complete. | |
| INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) | |
| Foo | |
| INFO: 127.0.0.1:48362 - "GET / HTTP/1.1" 200 OK | |
| INFO: 127.0.0.1:48364 - "GET /hello/User HTTP/1.1" 500 Internal Server Error | |
| ERROR: Exception in ASGI application | |
| Traceback (most recent call last): | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/uvicorn/protocols/http/h11_impl.py", line 410, in run_asgi | |
| result = await app( # type: ignore[func-returns-value] | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| self.scope, self.receive, self.send | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| ) | |
| ^ | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__ | |
| return await self.app(scope, receive, send) | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/fastapi/applications.py", line 1134, in __call__ | |
| await super().__call__(scope, receive, send) | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/starlette/applications.py", line 107, in __call__ | |
| await self.middleware_stack(scope, receive, send) | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/starlette/middleware/errors.py", line 186, in __call__ | |
| raise exc | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/starlette/middleware/errors.py", line 164, in __call__ | |
| await self.app(scope, receive, _send) | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/starlette/middleware/exceptions.py", line 63, in __call__ | |
| await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app | |
| raise exc | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app | |
| await app(scope, receive, sender) | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__ | |
| await self.app(scope, receive, send) | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/starlette/routing.py", line 716, in __call__ | |
| await self.middleware_stack(scope, receive, send) | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/starlette/routing.py", line 736, in app | |
| await route.handle(scope, receive, send) | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/starlette/routing.py", line 290, in handle | |
| await self.app(scope, receive, send) | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/fastapi/routing.py", line 119, in app | |
| await wrap_app_handling_exceptions(app, request)(scope, receive, send) | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app | |
| raise exc | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app | |
| await app(scope, receive, sender) | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/fastapi/routing.py", line 105, in app | |
| response = await f(request) | |
| ^^^^^^^^^^^^^^^^ | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/fastapi/routing.py", line 424, in app | |
| raw_response = await run_endpoint_function( | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| ...<3 lines>... | |
| ) | |
| ^ | |
| File "/home/gounlaf/code/mre-wireup-issue/.venv/lib/python3.14/site-packages/fastapi/routing.py", line 312, in run_endpoint_function | |
| return await dependant.call(**values) | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| File "<string>", line 6, in _wireup_generated_wrapper | |
| TypeError: 'BarOverride' object can't be awaited |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /home/linuxbrew/.linuxbrew/bin/uv run /home/gounlaf/code/mre-wireup-issue/.venv/bin/python /home/gounlaf/code/mre-wireup-issue/main.py | |
| INFO: Started server process [794841] | |
| INFO: Waiting for application startup. | |
| INFO: Application startup complete. | |
| INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) | |
| Foo | |
| INFO: 127.0.0.1:50542 - "GET / HTTP/1.1" 200 OK | |
| Bar | |
| INFO: 127.0.0.1:55044 - "GET /hello/User HTTP/1.1" 200 OK |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from fastapi import FastAPI, APIRouter | |
| from wireup import Injected | |
| import wireup.integration.fastapi | |
| import services | |
| from services import BarDep | |
| router = APIRouter(route_class=wireup.integration.fastapi.WireupRoute) | |
| container = wireup.create_async_container( | |
| # Add the integration module to injectables | |
| injectables=[services, wireup.integration.fastapi], | |
| ) | |
| @router.get("/") | |
| async def root(foo: Injected[services.FooDep]): | |
| foo.print() | |
| return {"message": "Hello World"} | |
| @router.get("/hello/{name}") | |
| async def say_hello(bar: Injected[services.BarDep], name: str): | |
| bar.print() | |
| return {"message": f"Hello {name}"} | |
| app = FastAPI() | |
| app.include_router(router) | |
| wireup.integration.fastapi.setup(container, app) | |
| if __name__ == "__main__": | |
| import uvicorn | |
| class BarOverride: | |
| def print(self): | |
| print("BarOverride") | |
| # issue when overriding | |
| with container.override.injectable(BarDep, BarOverride()): | |
| uvicorn.run(app, host="0.0.0.0", port=8000) | |
| # no issue when not overriding | |
| #uvicorn.run(app, host="0.0.0.0", port=8000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [project] | |
| name = "mre-wireup-issue" | |
| version = "0.1.0" | |
| description = "Add your description here" | |
| requires-python = ">=3.12" | |
| dependencies = [ | |
| "fastapi>=0.129.0", | |
| "uvicorn>=0.41.0", | |
| "wireup>=2.7.0", | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from wireup import injectable | |
| class FooDep: | |
| def print(self): | |
| print("Foo") | |
| class BarDep: | |
| def print(self): | |
| print("Bar") | |
| @injectable(lifetime="scoped") | |
| def foo_factory() -> FooDep: | |
| return FooDep() | |
| @injectable(lifetime="scoped") | |
| async def bar_factory() -> BarDep: | |
| return BarDep() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment