Skip to content

chore(python-sdk): modernise type hints #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stevenh
Copy link
Contributor

@stevenh stevenh commented Jun 4, 2025

Leverage future import annotations to enable support for streamlined type hints using | vs Union from PEP 604.

Future annotations was enabled across the codebase so that any additional use of Optional or Union would be flagged by type linters.

Removed unused imports, guarded import under TYPE_CHECKING where necessary.

Fixed accept parameter definition for EventEncoder and added a missing comment.

Fixes: #50

@stevenh stevenh changed the title chore: modernise type hints chore(python-sdk): modernise type hints Jun 4, 2025
@stevenh stevenh force-pushed the core/modern-union branch 2 times, most recently from 6f2b6a7 to a4a8daf Compare June 4, 2025 07:24
Leverage __future__ import annotations to enable support for streamlined
type hints using | vs Union from PEP 604.

Future annotations was enabled across the codebase so that any
additional use of Optional or Union would be flagged by type linters.

Removed unused imports, guarded import under TYPE_CHECKING where
necessary.

Fixed accept parameter definition for EventEncoder and added a missing
comment.

Fixes: ag-ui-protocol#50
@stevenh stevenh force-pushed the core/modern-union branch from a4a8daf to f492e53 Compare June 4, 2025 07:28
@stevenh stevenh marked this pull request as ready for review June 4, 2025 07:29
@tylerslaton tylerslaton requested review from Copilot and mme June 4, 2025 13:51
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Modernize type hints across the Python SDK by enabling postponed evaluation of annotations, replacing Union/Optional with |, cleaning up imports, and tightening the EventEncoder initializer.

  • Add from __future__ import annotations and use PEP 604 unions everywhere.
  • Remove unused imports and guard imports under TYPE_CHECKING.
  • Update EventEncoder.__init__ signature and add a basic docstring.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
python-sdk/tests/test_types.py Added future annotations import for streamlined type hints.
python-sdk/tests/test_events.py Added annotations import; removed unused json and Message.
python-sdk/tests/test_encoder.py Added future annotations import.
python-sdk/ag_ui/encoder/encoder.py Guarded event type import, updated __init__ signature and doc.
python-sdk/ag_ui/encoder/init.py Added future annotations import.
python-sdk/ag_ui/core/types.py Replaced Union/Optional with `
python-sdk/ag_ui/core/events.py Replaced Optional[...] with `
python-sdk/ag_ui/core/init.py Added future annotations import.
Comments suppressed due to low confidence (1)

python-sdk/ag_ui/encoder/encoder.py:20

  • Expand this docstring to document the accept parameter (its purpose, valid values, and default behavior) to improve clarity for future readers.
"""
        Initializes the EventEncoder.
        """

@stevenh
Copy link
Contributor Author

stevenh commented Jun 20, 2025

@NathanTarbert @mme could you have a look at this.

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.

python-sdk: use of modern type union operator
1 participant