Skip to content

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 3 times, most recently 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.

@stevenh
Copy link
Contributor Author

stevenh commented Jul 14, 2025

This needs updating with all the changes, so switching it back to draft

@stevenh stevenh marked this pull request as draft July 14, 2025 15:00
@stevenh stevenh force-pushed the core/modern-union branch 6 times, most recently from 3e787de to 0f35ef3 Compare July 16, 2025 08:14
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 0f35ef3 to 9bf0a19 Compare July 16, 2025 08:16
@stevenh
Copy link
Contributor Author

stevenh commented Jul 16, 2025

This won't be valid until 3.9 support is dropped, which is EOL October 2025

@tylerslaton
Copy link
Contributor

Hi @stevenh we're just going back through old PR's - is this still relevant? If so could you help to get it rebased so we can merge it?

@stevenh
Copy link
Contributor Author

stevenh commented Sep 11, 2025

It is still relevant, but I wouldn't recommend applying until you remove support for python 3.9, which is end of life in October.

Do you have a supported versions policy?

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
2 participants