Repository navigation
Treat typing.Dict[str, X] return annotations like dict[str, X]
#3756
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
Changes from all commits
9d07811
fb9f5d1
869d4d8
c38a652
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ | |
| import sys | ||
| from collections.abc import Awaitable, Callable, Sequence | ||
| from itertools import chain | ||
| from types import GenericAlias | ||
| from typing import Annotated, Any, NotRequired, Union, cast, get_args, get_origin | ||
|
|
||
| import anyio | ||
|
|
@@ -512,10 +511,8 @@ def _create_output_model(original_annotation: Any, type_expr: Any, func_name: st | |
| model = _create_wrapped_model(func_name, original_annotation) | ||
| wrap_output = True | ||
|
|
||
| # Handle GenericAlias types (list[str], dict[str, int], Union[str, int], etc.) | ||
| elif isinstance(type_expr, GenericAlias): | ||
| origin = get_origin(type_expr) | ||
|
|
||
| # Handle parameterized generics (list[str], typing.Dict[str, int], Union[str, int], etc.) | ||
| elif (origin := get_origin(type_expr)) is not None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 (optional) Tools returning Why this was flaggedA tool annotated Verification: Triggers when a tool's return annotation is Finding ID: |
||
| if origin is dict: | ||
| args = get_args(type_expr) | ||
| if len(args) == 2 and args[0] is str: | ||
|
Comment on lines
+515
to
518
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For existing tools annotated with AGENTS.md reference: AGENTS.md:L144-L148 Useful? React with 👍 / 👎. |
||
|
|
@@ -558,8 +555,6 @@ def _create_output_model(original_annotation: Any, type_expr: Any, func_name: st | |
|
|
||
| # Handle any other types not covered above | ||
| else: | ||
| # This includes typing constructs that aren't GenericAlias in Python 3.10 | ||
| # (e.g., Union, Optional in some Python versions) | ||
| model = _create_wrapped_model(func_name, original_annotation) | ||
| wrap_output = True | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.