-
Notifications
You must be signed in to change notification settings - Fork 624
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
base: main
Are you sure you want to change the base?
Conversation
a4a8daf
to
f492e53
Compare
There was a problem hiding this 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.
"""
@NathanTarbert @mme could you have a look at this. |
This needs updating with all the changes, so switching it back to draft |
3e787de
to
0f35ef3
Compare
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
0f35ef3
to
9bf0a19
Compare
This won't be valid until 3.9 support is dropped, which is EOL October 2025 |
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? |
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? |
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