Skip to content

Commit d29c63a

Browse files
committed
Check FastAPI package on A2AFastAPIApplication()
On app initialization with app = A2aFastAPIApplication(), check that the FastAPI package is installed and raise ImportError with the custom messsage if necessary.
1 parent 012ea77 commit d29c63a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/a2a/server/apps/jsonrpc/fastapi_app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ def __init__(
5252
context_builder=context_builder,
5353
)
5454

55+
self._check_fastapi_dependency()
56+
57+
def _check_fastapi_dependency(self) -> None:
58+
"""Checks if the FastAPI package is installed.
59+
60+
If instead of the actual FastAPI class, a dummy implementation from
61+
./fastapi_import_helpers.py is imported, initializing FastAPI() would
62+
raise ImportError.
63+
"""
64+
_app = FastAPI()
65+
5566
def add_routes_to_app(
5667
self,
5768
app: FastAPI,

0 commit comments

Comments
 (0)