Skip to content

Commit 583d60a

Browse files
Linux2010claude
andcommitted
fix: replace deprecated FieldDescriptor.label with is_repeated in proto_utils
Use the non-deprecated FieldDescriptor.is_repeated property instead of comparing field.label to LABEL_REPEATED. Remove all TODO comments referencing issue #1011. Closes #1011 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 75991c1 commit 583d60a

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

src/a2a/utils/proto_utils.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,7 @@ def parse_params(params: QueryParams, message: ProtobufMessage) -> None:
174174
field = fields[k]
175175
v_list = params.getlist(k)
176176

177-
# TODO(https://github.com/a2aproject/a2a-python/issues/1011): Replace
178-
# deprecated `field.label` with `field.is_repeated` once the minimum
179-
# protobuf version requirement is bumped.
180-
if field.label == FieldDescriptor.LABEL_REPEATED:
177+
if field.is_repeated:
181178
accumulated: list[Any] = []
182179
for v in v_list:
183180
if not v:
@@ -211,10 +208,7 @@ def _check_required_field_violation(
211208
) -> ValidationDetail | None:
212209
"""Check if a required field is missing or invalid."""
213210
val = getattr(msg, field.name)
214-
# TODO(https://github.com/a2aproject/a2a-python/issues/1011): Replace
215-
# deprecated `field.label` with `field.is_repeated` once the minimum
216-
# protobuf version requirement is bumped.
217-
if field.label == FieldDescriptor.LABEL_REPEATED:
211+
if field.is_repeated:
218212
if not val:
219213
return ValidationDetail(
220214
field=field.name,
@@ -255,10 +249,7 @@ def _recurse_validation(
255249
return errors
256250

257251
val = getattr(msg, field.name)
258-
# TODO(https://github.com/a2aproject/a2a-python/issues/1011): Replace
259-
# deprecated `field.label` with `field.is_repeated` once the minimum
260-
# protobuf version requirement is bumped.
261-
if field.label != FieldDescriptor.LABEL_REPEATED:
252+
if not field.is_repeated:
262253
if msg.HasField(field.name):
263254
sub_errs = _validate_proto_required_fields_internal(val)
264255
_append_nested_errors(errors, field.name, sub_errs)

0 commit comments

Comments
 (0)