Skip to content

refactor: unify transport name constants usage#728

Merged
ishymko merged 3 commits into
1.0-devfrom
ishymko/716-fix
Feb 23, 2026
Merged

refactor: unify transport name constants usage#728
ishymko merged 3 commits into
1.0-devfrom
ishymko/716-fix

Conversation

@ishymko
Copy link
Copy Markdown
Member

@ishymko ishymko commented Feb 23, 2026

Use enum everywhere, data model uses str for protocol names, so custom protocols won't be constrained with the enum.

Fixes #705

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @ishymko, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the handling of transport protocol constants by migrating from individual string constants to a unified TransportProtocol str Enum. This change, which addresses issue #705, improves code consistency, type safety, and maintainability by centralizing the definition and usage of transport protocols throughout the A2A SDK.

Highlights

  • Unified Transport Constants: Converted the TransportProtocol class into a str Enum in src/a2a/utils/constants.py to centralize and standardize transport protocol definitions.
  • Codebase-Wide Constant Replacement: Replaced all instances of the old string constants (TRANSPORT_GRPC, TRANSPORT_HTTP_JSON, TRANSPORT_JSONRPC) with their corresponding TransportProtocol enum members across the entire codebase, including client factories, transports, and test files.
  • Improved Type Safety and Readability: Enhanced type safety and code readability by ensuring that transport protocols are consistently referenced through enum members, which also helps prevent potential errors from string mismatches.
Changelog
  • src/a2a/client/client_factory.py
    • Updated transport protocol references to use TransportProtocol enum members.
  • src/a2a/client/transports/rest.py
    • Updated transport protocol references to use TransportProtocol enum members.
  • src/a2a/utils/init.py
    • Removed deprecated transport string constants from imports and __all__ export list.
  • src/a2a/utils/constants.py
    • Refactored TransportProtocol into a str Enum.
    • Removed old, individual transport string constants.
  • tests/client/test_auth_middleware.py
    • Updated AgentInterface protocol binding and ClientConfig supported protocols to use TransportProtocol enum members.
  • tests/client/test_client_factory.py
    • Updated AgentInterface protocol binding and ClientConfig supported protocols to use TransportProtocol enum members.
    • Adjusted an assertion for extensions.
  • tests/client/transports/test_rest_client.py
    • Updated AgentInterface protocol binding to use TransportProtocol enum members.
    • Reordered an import.
  • tests/e2e/push_notifications/test_default_push_notification_support.py
    • Updated ClientConfig supported protocols and minimal_agent_card calls to use TransportProtocol enum members.
  • tests/integration/test_client_server_integration.py
    • Updated AgentInterface protocol binding to use TransportProtocol enum members.
    • Removed deprecated transport constants from imports.
  • tests/integration/test_end_to_end.py
    • Updated AgentInterface protocol binding to use TransportProtocol enum members.
    • Removed deprecated transport constants from imports.
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a well-executed refactoring that unifies the usage of transport protocol constants into a TransportProtocol enum. This change significantly improves code clarity, maintainability, and type safety. The refactoring has been applied consistently across both the application logic and the test suite. I have one minor suggestion to improve the readability of a type hint, but overall, the changes are excellent.

Comment thread tests/client/test_client_factory.py Outdated
@ishymko ishymko changed the title refactor: unify transport constants usage refactor: unify transport name constants usage Feb 23, 2026
@ishymko ishymko marked this pull request as ready for review February 23, 2026 14:48
@ishymko ishymko requested a review from a team as a code owner February 23, 2026 14:48
@ishymko ishymko merged commit 639a663 into 1.0-dev Feb 23, 2026
10 checks passed
@ishymko ishymko deleted the ishymko/716-fix branch February 23, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants