Skip to content

Commit b280743

Browse files
authored
Update src/a2a/server/apps/jsonrpc/jsonrpc_app.py
1 parent 111ca00 commit b280743

File tree

1 file changed

+2
-29
lines changed

1 file changed

+2
-29
lines changed

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

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -170,35 +170,8 @@ class JSONRPCApplication(ABC):
170170
| GetAuthenticatedExtendedCardRequest
171171
)
172172

173-
# Pydantic model fields like 'method' are instance attributes, not class attributes.
174-
# So, 'Type.method' does not exist until you instantiate the model.
175-
# To get the default value for the 'method' field at the class level,
176-
# you must use Type.model_fields["method"].default.
177-
METHOD_TO_MODEL: dict[str, type[A2ARequestModel]] = {
178-
SendMessageRequest.model_fields['method'].default: SendMessageRequest,
179-
SendStreamingMessageRequest.model_fields[
180-
'method'
181-
].default: SendStreamingMessageRequest,
182-
GetTaskRequest.model_fields['method'].default: GetTaskRequest,
183-
CancelTaskRequest.model_fields['method'].default: CancelTaskRequest,
184-
SetTaskPushNotificationConfigRequest.model_fields[
185-
'method'
186-
].default: SetTaskPushNotificationConfigRequest,
187-
GetTaskPushNotificationConfigRequest.model_fields[
188-
'method'
189-
].default: GetTaskPushNotificationConfigRequest,
190-
ListTaskPushNotificationConfigRequest.model_fields[
191-
'method'
192-
].default: ListTaskPushNotificationConfigRequest,
193-
DeleteTaskPushNotificationConfigRequest.model_fields[
194-
'method'
195-
].default: DeleteTaskPushNotificationConfigRequest,
196-
TaskResubscriptionRequest.model_fields[
197-
'method'
198-
].default: TaskResubscriptionRequest,
199-
GetAuthenticatedExtendedCardRequest.model_fields[
200-
'method'
201-
].default: GetAuthenticatedExtendedCardRequest,
173+
METHOD_TO_MODEL = {
174+
model.model_fields["method"].default: model for model in A2ARequestModel.__args__
202175
}
203176

204177
def __init__( # noqa: PLR0913

0 commit comments

Comments
 (0)