Skip to content

Commit adc2ba9

Browse files
committed
refactor(grpc): eliminate third-party grpcio-status dependency
Replaced grpcio-status imports with local implementations _from_call and _to_status in client and server transport layers. Removed the grpcio-status dependency from pyproject.toml.
1 parent e7eafe3 commit adc2ba9

4 files changed

Lines changed: 1437 additions & 1420 deletions

File tree

pyproject.toml

Lines changed: 124 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ classifiers = [
3737
http-server = ["sse-starlette", "starlette"]
3838
fastapi = ["a2a-sdk[http-server]", "fastapi>=0.115.2"]
3939
encryption = ["cryptography>=43.0.0"]
40-
grpc = ["grpcio>=1.60", "grpcio-tools>=1.60", "grpcio-status>=1.60", "grpcio_reflection>=1.7.0"]
40+
grpc = ["grpcio>=1.60", "grpcio-tools>=1.60", "grpcio_reflection>=1.7.0"]
4141
telemetry = ["opentelemetry-api>=1.33.0", "opentelemetry-sdk>=1.33.0"]
4242
postgresql = ["sqlalchemy[asyncio,postgresql-asyncpg]>=2.0.0"]
4343
mysql = ["sqlalchemy[asyncio,aiomysql]>=2.0.0"]
@@ -94,7 +94,7 @@ filterwarnings = [
9494
# ResourceWarnings from asyncio event loop/socket cleanup during garbage collection
9595
# These appear intermittently between tests due to pytest-asyncio and sse-starlette timing
9696
"ignore:unclosed event loop:ResourceWarning",
97-
"ignore:unclosed transport:ResourceWarning",
97+
"ignore:unclosed transport:ResourceWarning",
9898
"ignore:unclosed <socket.socket:ResourceWarning",
9999
]
100100

@@ -158,24 +158,24 @@ exclude = [
158158
[tool.coverage.run]
159159
branch = true
160160
omit = [
161-
"*/tests/*",
162-
"*/site-packages/*",
163-
"*/__init__.py",
164-
"src/a2a/types/a2a_pb2.py",
165-
"src/a2a/types/a2a_pb2_grpc.py",
166-
"src/a2a/compat/*/*_pb2*.py",
161+
"*/tests/*",
162+
"*/site-packages/*",
163+
"*/__init__.py",
164+
"src/a2a/types/a2a_pb2.py",
165+
"src/a2a/types/a2a_pb2_grpc.py",
166+
"src/a2a/compat/*/*_pb2*.py",
167167
]
168168

169169
[tool.coverage.report]
170170
exclude_lines = [
171-
"pragma: no cover",
172-
"import",
173-
"def __repr__",
174-
"raise NotImplementedError",
175-
"if TYPE_CHECKING",
176-
"@abstractmethod",
177-
"pass",
178-
"raise ImportError",
171+
"pragma: no cover",
172+
"import",
173+
"def __repr__",
174+
"raise NotImplementedError",
175+
"if TYPE_CHECKING",
176+
"@abstractmethod",
177+
"pass",
178+
"raise ImportError",
179179
]
180180

181181
#
@@ -184,105 +184,105 @@ exclude_lines = [
184184
[tool.ruff]
185185
# This file follows the standards in Google Python Style Guide
186186
# https://google.github.io/styleguide/pyguide.html
187-
line-length = 80 # Google Style Guide §3.2: 80 columns
188-
indent-width = 4 # Google Style Guide §3.4: 4 spaces
187+
line-length = 80 # Google Style Guide §3.2: 80 columns
188+
indent-width = 4 # Google Style Guide §3.4: 4 spaces
189189
target-version = "py310" # Minimum Python version
190190

191191
[tool.ruff.lint]
192192
preview = true
193193
explicit-preview-rules = true
194194
ignore = [
195-
"COM812", # Trailing comma missing.
196-
"FBT001", # Boolean positional arg in function definition
197-
"FBT002", # Boolean default value in function definition
198-
"D203", # 1 blank line required before class docstring (Google: 0)
199-
"D213", # Multi-line docstring summary should start at the second line (Google: first line)
200-
"D100", # Ignore Missing docstring in public module (often desired at top level __init__.py)
201-
"D104", # Ignore Missing docstring in public package (often desired at top level __init__.py)
202-
"D107", # Ignore Missing docstring in __init__ (use class docstring)
203-
"TD002", # Ignore Missing author in TODOs (often not required)
204-
"TD003", # Ignore Missing issue link in TODOs (often not required/available)
205-
"T201", # Ignore print presence
206-
"RUF012", # Ignore Mutable class attributes should be annotated with `typing.ClassVar`
207-
"E501", # Ignore line length (handled by Ruff's dynamic line length)
208-
"ANN002",
209-
"ANN003",
210-
"ANN401",
211-
"TRY003",
212-
"TRY201",
213-
"FIX002",
195+
"COM812", # Trailing comma missing.
196+
"FBT001", # Boolean positional arg in function definition
197+
"FBT002", # Boolean default value in function definition
198+
"D203", # 1 blank line required before class docstring (Google: 0)
199+
"D213", # Multi-line docstring summary should start at the second line (Google: first line)
200+
"D100", # Ignore Missing docstring in public module (often desired at top level __init__.py)
201+
"D104", # Ignore Missing docstring in public package (often desired at top level __init__.py)
202+
"D107", # Ignore Missing docstring in __init__ (use class docstring)
203+
"TD002", # Ignore Missing author in TODOs (often not required)
204+
"TD003", # Ignore Missing issue link in TODOs (often not required/available)
205+
"T201", # Ignore print presence
206+
"RUF012", # Ignore Mutable class attributes should be annotated with `typing.ClassVar`
207+
"E501", # Ignore line length (handled by Ruff's dynamic line length)
208+
"ANN002",
209+
"ANN003",
210+
"ANN401",
211+
"TRY003",
212+
"TRY201",
213+
"FIX002",
214214
]
215215

216216
select = [
217-
"E", # pycodestyle errors (PEP 8)
218-
"W", # pycodestyle warnings (PEP 8)
219-
"F", # Pyflakes (logical errors, unused imports/variables)
220-
"I", # isort (import sorting - Google Style §3.1.2)
221-
"D", # pydocstyle (docstring conventions - Google Style §3.8)
222-
"N", # pep8-naming (naming conventions - Google Style §3.16)
223-
"UP", # pyupgrade (use modern Python syntax)
224-
"ANN",# flake8-annotations (type hint usage/style - Google Style §2.22)
225-
"A", # flake8-builtins (avoid shadowing builtins)
226-
"B", # flake8-bugbear (potential logic errors & style issues - incl. mutable defaults B006, B008)
227-
"C4", # flake8-comprehensions (unnecessary list/set/dict comprehensions)
228-
"ISC",# flake8-implicit-str-concat (disallow implicit string concatenation across lines)
229-
"T20",# flake8-print (discourage `print` - prefer logging)
230-
"SIM",# flake8-simplify (simplify code, e.g., `if cond: return True else: return False`)
231-
"PTH",# flake8-use-pathlib (use pathlib instead of os.path where possible)
232-
"PL", # Pylint rules ported to Ruff (PLC, PLE, PLR, PLW)
233-
"PIE",# flake8-pie (misc code improvements, e.g., no-unnecessary-pass)
234-
"RUF",# Ruff-specific rules (e.g., RUF001-003 ambiguous unicode, RUF013 implicit optional)
235-
"RET",# flake8-return (consistency in return statements)
236-
"SLF",# flake8-self (check for private member access via `self`)
237-
"TID",# flake8-tidy-imports (relative imports, banned imports - configure if needed)
238-
"YTT",# flake8-boolean-trap (checks for boolean positional arguments, truthiness tests - Google Style §3.10)
239-
"TD", # flake8-todos (check TODO format - Google Style §3.7)
240-
"TCH",# flake8-type-checking (helps manage TYPE_CHECKING blocks and imports)
241-
"PYI",# flake8-pyi (best practices for .pyi stub files, some rules are useful for .py too)
242-
"S", # flake8-bandit (security issues)
243-
"DTZ",# flake8-datetimez (timezone-aware datetimes)
244-
"ERA",# flake8-eradicate (commented-out code)
245-
"Q", # flake8-quotes (quote style consistency)
246-
"RSE",# flake8-raise (modern raise statements)
247-
"TRY",# tryceratops (exception handling best practices)
248-
"PERF",# perflint (performance anti-patterns)
249-
"BLE",
250-
"T10",
251-
"ICN",
252-
"G",
253-
"FIX",
254-
"ASYNC",
255-
"INP",
217+
"E", # pycodestyle errors (PEP 8)
218+
"W", # pycodestyle warnings (PEP 8)
219+
"F", # Pyflakes (logical errors, unused imports/variables)
220+
"I", # isort (import sorting - Google Style §3.1.2)
221+
"D", # pydocstyle (docstring conventions - Google Style §3.8)
222+
"N", # pep8-naming (naming conventions - Google Style §3.16)
223+
"UP", # pyupgrade (use modern Python syntax)
224+
"ANN", # flake8-annotations (type hint usage/style - Google Style §2.22)
225+
"A", # flake8-builtins (avoid shadowing builtins)
226+
"B", # flake8-bugbear (potential logic errors & style issues - incl. mutable defaults B006, B008)
227+
"C4", # flake8-comprehensions (unnecessary list/set/dict comprehensions)
228+
"ISC", # flake8-implicit-str-concat (disallow implicit string concatenation across lines)
229+
"T20", # flake8-print (discourage `print` - prefer logging)
230+
"SIM", # flake8-simplify (simplify code, e.g., `if cond: return True else: return False`)
231+
"PTH", # flake8-use-pathlib (use pathlib instead of os.path where possible)
232+
"PL", # Pylint rules ported to Ruff (PLC, PLE, PLR, PLW)
233+
"PIE", # flake8-pie (misc code improvements, e.g., no-unnecessary-pass)
234+
"RUF", # Ruff-specific rules (e.g., RUF001-003 ambiguous unicode, RUF013 implicit optional)
235+
"RET", # flake8-return (consistency in return statements)
236+
"SLF", # flake8-self (check for private member access via `self`)
237+
"TID", # flake8-tidy-imports (relative imports, banned imports - configure if needed)
238+
"YTT", # flake8-boolean-trap (checks for boolean positional arguments, truthiness tests - Google Style §3.10)
239+
"TD", # flake8-todos (check TODO format - Google Style §3.7)
240+
"TCH", # flake8-type-checking (helps manage TYPE_CHECKING blocks and imports)
241+
"PYI", # flake8-pyi (best practices for .pyi stub files, some rules are useful for .py too)
242+
"S", # flake8-bandit (security issues)
243+
"DTZ", # flake8-datetimez (timezone-aware datetimes)
244+
"ERA", # flake8-eradicate (commented-out code)
245+
"Q", # flake8-quotes (quote style consistency)
246+
"RSE", # flake8-raise (modern raise statements)
247+
"TRY", # tryceratops (exception handling best practices)
248+
"PERF", # perflint (performance anti-patterns)
249+
"BLE",
250+
"T10",
251+
"ICN",
252+
"G",
253+
"FIX",
254+
"ASYNC",
255+
"INP",
256256
]
257257

258258
exclude = [
259-
".bzr",
260-
".direnv",
261-
".eggs",
262-
".git",
263-
".hg",
264-
".mypy_cache",
265-
".nox",
266-
".pants.d",
267-
".pytype",
268-
".ruff_cache",
269-
".svn",
270-
".tox",
271-
".venv",
272-
"__pypackages__",
273-
"_build",
274-
"buck-out",
275-
"build",
276-
"dist",
277-
"node_modules",
278-
"venv",
279-
"*/migrations/*",
280-
"src/a2a/types/a2a_pb2.py",
281-
"src/a2a/types/a2a_pb2.pyi",
282-
"src/a2a/types/a2a_pb2_grpc.py",
283-
"src/a2a/compat/v0_3/*_pb2.py",
284-
"src/a2a/compat/v0_3/*_pb2.pyi",
285-
"src/a2a/compat/v0_3/*_pb2_grpc.py",
259+
".bzr",
260+
".direnv",
261+
".eggs",
262+
".git",
263+
".hg",
264+
".mypy_cache",
265+
".nox",
266+
".pants.d",
267+
".pytype",
268+
".ruff_cache",
269+
".svn",
270+
".tox",
271+
".venv",
272+
"__pypackages__",
273+
"_build",
274+
"buck-out",
275+
"build",
276+
"dist",
277+
"node_modules",
278+
"venv",
279+
"*/migrations/*",
280+
"src/a2a/types/a2a_pb2.py",
281+
"src/a2a/types/a2a_pb2.pyi",
282+
"src/a2a/types/a2a_pb2_grpc.py",
283+
"src/a2a/compat/v0_3/*_pb2.py",
284+
"src/a2a/compat/v0_3/*_pb2.pyi",
285+
"src/a2a/compat/v0_3/*_pb2_grpc.py",
286286
]
287287

288288
[tool.ruff.lint.isort]
@@ -300,7 +300,11 @@ allow-star-arg-any = false
300300

301301
[tool.ruff.lint.pep8-naming]
302302
ignore-names = ["test_*", "setUp", "tearDown", "mock_*"]
303-
classmethod-decorators = ["classmethod", "pydantic.validator", "pydantic.root_validator"]
303+
classmethod-decorators = [
304+
"classmethod",
305+
"pydantic.validator",
306+
"pydantic.root_validator",
307+
]
304308
staticmethod-decorators = ["staticmethod"]
305309

306310
[tool.ruff.lint.flake8-tidy-imports]
@@ -311,36 +315,29 @@ docstring-quotes = "double"
311315
inline-quotes = "single"
312316

313317
[tool.ruff.lint.per-file-ignores]
314-
"__init__.py" = ["F401", "D", "ANN"] # Ignore unused imports in __init__.py
318+
"__init__.py" = ["F401", "D", "ANN"] # Ignore unused imports in __init__.py
315319
"*_test.py" = [
316-
"D", # All pydocstyle rules
317-
"ANN", # Missing type annotation for function argument
318-
"RUF013", # Implicit optional type in test function signatures
319-
"S101", # Use of `assert` detected (expected in tests)
320-
"PLR2004",
321-
"SLF001",
322-
]
323-
"test_*.py" = [
324-
"D",
325-
"ANN",
326-
"RUF013",
327-
"S101",
328-
"PLR2004",
329-
"SLF001",
320+
"D", # All pydocstyle rules
321+
"ANN", # Missing type annotation for function argument
322+
"RUF013", # Implicit optional type in test function signatures
323+
"S101", # Use of `assert` detected (expected in tests)
324+
"PLR2004",
325+
"SLF001",
330326
]
331-
"types.py" = ["D", "E501"] # Ignore docstring and annotation issues in types.py
327+
"test_*.py" = ["D", "ANN", "RUF013", "S101", "PLR2004", "SLF001"]
328+
"types.py" = ["D", "E501"] # Ignore docstring and annotation issues in types.py
332329
"proto_utils.py" = ["D102", "PLR0911"]
333330
"helpers.py" = ["ANN001", "ANN201", "ANN202"]
334331
"scripts/*.py" = ["INP001"]
335332

336333
[tool.ruff.format]
337334
exclude = [
338-
"src/a2a/types/a2a_pb2.py",
339-
"src/a2a/types/a2a_pb2.pyi",
340-
"src/a2a/types/a2a_pb2_grpc.py",
341-
"src/a2a/compat/v0_3/*_pb2.py",
342-
"src/a2a/compat/v0_3/*_pb2.pyi",
343-
"src/a2a/compat/v0_3/*_pb2_grpc.py",
335+
"src/a2a/types/a2a_pb2.py",
336+
"src/a2a/types/a2a_pb2.pyi",
337+
"src/a2a/types/a2a_pb2_grpc.py",
338+
"src/a2a/compat/v0_3/*_pb2.py",
339+
"src/a2a/compat/v0_3/*_pb2.pyi",
340+
"src/a2a/compat/v0_3/*_pb2_grpc.py",
344341
]
345342
docstring-code-format = true
346343
docstring-code-line-length = "dynamic"
@@ -354,9 +351,7 @@ indent-style = "space"
354351
script_location = "src/a2a/migrations"
355352

356353
# additional paths to be prepended to sys.path. defaults to the current working directory.
357-
prepend_sys_path = [
358-
"src"
359-
]
354+
prepend_sys_path = ["src"]
360355

361356
[project.scripts]
362357
a2a-db = "a2a.a2a_db_cli:run_migrations"

0 commit comments

Comments
 (0)