diff --git a/GEMINI.md b/GEMINI.md index aaab0bf66..59ef64713 100644 --- a/GEMINI.md +++ b/GEMINI.md @@ -8,7 +8,7 @@ - **Language**: Python 3.10+ - **Package Manager**: `uv` -- **Lead Transports**: FastAPI (REST/JSON-RPC), gRPC +- **Lead Transports**: Starlette (REST/JSON-RPC), gRPC - **Data Layer**: SQLAlchemy (SQL), Pydantic (Logic/Legacy), Protobuf (Modern Messaging) - **Key Directories**: - `/src`: Core implementation logic. diff --git a/pyproject.toml b/pyproject.toml index ac2083b16..724749865 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ classifiers = [ ] [project.optional-dependencies] -http-server = ["fastapi>=0.115.2", "sse-starlette", "starlette"] +http-server = ["sse-starlette", "starlette"] encryption = ["cryptography>=43.0.0"] grpc = ["grpcio>=1.60", "grpcio-tools>=1.60", "grpcio-status>=1.60", "grpcio_reflection>=1.7.0"] telemetry = ["opentelemetry-api>=1.33.0", "opentelemetry-sdk>=1.33.0"] @@ -107,6 +107,7 @@ style = "pep440" [dependency-groups] dev = [ + "fastapi>=0.115.2", "mypy>=1.15.0", "PyJWT>=2.0.0", "pytest>=8.3.5", diff --git a/src/a2a/server/routes/jsonrpc_dispatcher.py b/src/a2a/server/routes/jsonrpc_dispatcher.py index c17801606..e0f0042b0 100644 --- a/src/a2a/server/routes/jsonrpc_dispatcher.py +++ b/src/a2a/server/routes/jsonrpc_dispatcher.py @@ -62,10 +62,7 @@ logger = logging.getLogger(__name__) if TYPE_CHECKING: - from fastapi import FastAPI from sse_starlette.sse import EventSourceResponse - from starlette.applications import Starlette - from starlette.authentication import BaseUser from starlette.exceptions import HTTPException from starlette.requests import Request from starlette.responses import JSONResponse, Response @@ -80,11 +77,8 @@ _package_starlette_installed = True else: - FastAPI = Any try: from sse_starlette.sse import EventSourceResponse - from starlette.applications import Starlette - from starlette.authentication import BaseUser from starlette.exceptions import HTTPException from starlette.requests import Request from starlette.responses import JSONResponse, Response @@ -103,8 +97,6 @@ # Provide placeholder types for runtime type hinting when dependencies are not installed. # These will not be used if the code path that needs them is guarded by _http_server_installed. EventSourceResponse = Any - Starlette = Any - BaseUser = Any HTTPException = Any Request = Any JSONResponse = Any diff --git a/src/a2a/server/routes/rest_routes.py b/src/a2a/server/routes/rest_routes.py index 89ba63b8e..20a899ca4 100644 --- a/src/a2a/server/routes/rest_routes.py +++ b/src/a2a/server/routes/rest_routes.py @@ -14,25 +14,15 @@ if TYPE_CHECKING: - from sse_starlette.sse import EventSourceResponse - from starlette.requests import Request - from starlette.responses import JSONResponse, Response from starlette.routing import BaseRoute, Mount, Route _package_starlette_installed = True else: try: - from sse_starlette.sse import EventSourceResponse - from starlette.requests import Request - from starlette.responses import JSONResponse, Response from starlette.routing import BaseRoute, Mount, Route _package_starlette_installed = True except ImportError: - EventSourceResponse = Any - Request = Any - JSONResponse = Any - Response = Any Route = Any Mount = Any BaseRoute = Any diff --git a/uv.lock b/uv.lock index 5d7d3b6fb..dc87a7b6d 100644 --- a/uv.lock +++ b/uv.lock @@ -27,7 +27,6 @@ dependencies = [ all = [ { name = "alembic" }, { name = "cryptography" }, - { name = "fastapi" }, { name = "google-cloud-aiplatform" }, { name = "grpcio" }, { name = "grpcio-reflection" }, @@ -53,7 +52,6 @@ grpc = [ { name = "grpcio-tools" }, ] http-server = [ - { name = "fastapi" }, { name = "sse-starlette" }, { name = "starlette" }, ] @@ -83,6 +81,7 @@ vertex = [ [package.dev-dependencies] dev = [ { name = "a2a-sdk", extra = ["all"] }, + { name = "fastapi" }, { name = "mypy" }, { name = "pre-commit" }, { name = "pyjwt" }, @@ -109,8 +108,6 @@ requires-dist = [ { name = "cryptography", marker = "extra == 'all'", specifier = ">=43.0.0" }, { name = "cryptography", marker = "extra == 'encryption'", specifier = ">=43.0.0" }, { name = "culsans", marker = "python_full_version < '3.13'", specifier = ">=0.11.0" }, - { name = "fastapi", marker = "extra == 'all'", specifier = ">=0.115.2" }, - { name = "fastapi", marker = "extra == 'http-server'", specifier = ">=0.115.2" }, { name = "google-api-core", specifier = ">=1.26.0" }, { name = "google-cloud-aiplatform", marker = "extra == 'all'", specifier = ">=1.140.0" }, { name = "google-cloud-aiplatform", marker = "extra == 'vertex'", specifier = ">=1.140.0" }, @@ -154,6 +151,7 @@ provides-extras = ["all", "db-cli", "encryption", "grpc", "http-server", "mysql" [package.metadata.requires-dev] dev = [ { name = "a2a-sdk", extras = ["all"], editable = "." }, + { name = "fastapi", specifier = ">=0.115.2" }, { name = "mypy", specifier = ">=1.15.0" }, { name = "pre-commit" }, { name = "pyjwt", specifier = ">=2.0.0" }, @@ -820,7 +818,7 @@ wheels = [ [[package]] name = "fastapi" -version = "0.135.1" +version = "0.135.3" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "annotated-doc" }, @@ -829,9 +827,9 @@ dependencies = [ { name = "typing-extensions" }, { name = "typing-inspection" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/e7/7b/f8e0211e9380f7195ba3f3d40c292594fd81ba8ec4629e3854c353aaca45/fastapi-0.135.1.tar.gz", hash = "sha256:d04115b508d936d254cea545b7312ecaa58a7b3a0f84952535b4c9afae7668cd", size = 394962, upload-time = "2026-03-01T18:18:29.369Z" } +sdist = { url = "https://files.pythonhosted.org/packages/f7/e6/7adb4c5fa231e82c35b8f5741a9f2d055f520c29af5546fd70d3e8e1cd2e/fastapi-0.135.3.tar.gz", hash = "sha256:bd6d7caf1a2bdd8d676843cdcd2287729572a1ef524fc4d65c17ae002a1be654", size = 396524, upload-time = "2026-04-01T16:23:58.188Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/e4/72/42e900510195b23a56bde950d26a51f8b723846bfcaa0286e90287f0422b/fastapi-0.135.1-py3-none-any.whl", hash = "sha256:46e2fc5745924b7c840f71ddd277382af29ce1cdb7d5eab5bf697e3fb9999c9e", size = 116999, upload-time = "2026-03-01T18:18:30.831Z" }, + { url = "https://files.pythonhosted.org/packages/84/a4/5caa2de7f917a04ada20018eccf60d6cc6145b0199d55ca3711b0fc08312/fastapi-0.135.3-py3-none-any.whl", hash = "sha256:9b0f590c813acd13d0ab43dd8494138eb58e484bfac405db1f3187cfc5810d98", size = 117734, upload-time = "2026-04-01T16:23:59.328Z" }, ] [[package]]