Skip to content

Commit ddbfff9

Browse files
authored
style: standardize property null checks to use ternary operators (#354)
# Description ## Summary Standardizes property null check patterns across the codebase by converting early return style to ternary operator style for consistency. ## Changes - **RequestContext.configuration**: Converted from `if not self._params: return None` pattern to ternary operator - **RequestContext.metadata**: Converted from `if not self._params: return {}` pattern to ternary operator
1 parent d37ce7b commit ddbfff9

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

src/a2a/server/agent_execution/context.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ def context_id(self) -> str | None:
127127
@property
128128
def configuration(self) -> MessageSendConfiguration | None:
129129
"""The `MessageSendConfiguration` from the request, if available."""
130-
if not self._params:
131-
return None
132-
return self._params.configuration
130+
return self._params.configuration if self._params else None
133131

134132
@property
135133
def call_context(self) -> ServerCallContext | None:
@@ -139,9 +137,7 @@ def call_context(self) -> ServerCallContext | None:
139137
@property
140138
def metadata(self) -> dict[str, Any]:
141139
"""Metadata associated with the request, if available."""
142-
if not self._params:
143-
return {}
144-
return self._params.metadata or {}
140+
return self._params.metadata or {} if self._params else {}
145141

146142
def add_activated_extension(self, uri: str) -> None:
147143
"""Add an extension to the set of activated extensions for this request.

0 commit comments

Comments
 (0)