Skip to content

Remove typing.AwaitableGenerator - #14959

Draft
srittau wants to merge 8 commits into
python:mainfrom
srittau:rm-awaitable-generator
Draft

Remove typing.AwaitableGenerator#14959
srittau wants to merge 8 commits into
python:mainfrom
srittau:rm-awaitable-generator

Conversation

@srittau

@srittau srittau commented Nov 1, 2025

Copy link
Copy Markdown
Collaborator

Part of #7580

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

trio (https://github.com/python-trio/trio)
- src/trio/_socket.py:218: error: Incompatible return value type (got "list[tuple[Literal[AddressFamily.AF_INET], SocketKind, int, str, tuple[str, int]] | tuple[Literal[AddressFamily.AF_INET6], SocketKind, int, str, tuple[str, int, int, int] | tuple[int, bytes]]]", expected "list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]")  [return-value]
- src/trio/_socket.py:218: note: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
- src/trio/_socket.py:218: note: Consider using "Sequence" instead, which is covariant
- src/trio/_socket.py:247: error: Argument 1 to "to_thread_run_sync" has incompatible type "Callable[[bytes | str | None, bytes | str | int | None, int, int, int, int], list[tuple[Literal[AddressFamily.AF_INET], SocketKind, int, str, tuple[str, int]] | tuple[Literal[AddressFamily.AF_INET6], SocketKind, int, str, tuple[str, int, int, int] | tuple[int, bytes]]]]"; expected "Callable[[bytes | None, bytes | str | int | None, int, int, int, int], list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]]"  [arg-type]
- src/trio/_tests/test_socket.py:128: error: Argument 1 to "MonkeypatchedGAI" has incompatible type "Callable[[bytes | str | None, bytes | str | int | None, int, int, int, int], list[tuple[Literal[AddressFamily.AF_INET], SocketKind, int, str, tuple[str, int]] | tuple[Literal[AddressFamily.AF_INET6], SocketKind, int, str, tuple[str, int, int, int] | tuple[int, bytes]]]]"; expected "Callable[[str | bytes | None, str | bytes | int | None, int, int, int, int], list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]]"  [arg-type]
- src/trio/_tests/test_exports.py:167: error: Unused "type: ignore" comment  [unused-ignore]
- src/trio/_core/_tests/test_instrumentation.py:40: error: Unsupported operand types for in ("Task | None" and "Container[Task]")  [operator]
+ src/trio/_core/_traps.py:65: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 2.3.0
+ src/trio/_core/_traps.py:65: note: use --pdb to drop into pdb
+ Traceback (most recent call last):
+   File "mypy/checker.py", line 765, in accept
+   File "mypy/nodes.py", line 1358, in accept
+   File "mypy/checker.py", line 5757, in visit_decorator
+     self.visit_decorator_inner(e)
+   File "mypy/checker.py", line 5778, in visit_decorator_inner
+     ret_type = self.named_generic_type("typing.AwaitableGenerator", [ty, tc, tr, t])
+   File "mypy/checker.py", line 7889, in named_generic_type
+     info = self.lookup_typeinfo(name)
+   File "mypy/checker.py", line 7896, in lookup_typeinfo
+     sym = self.lookup_qualified(fullname)
+   File "mypy/checker.py", line 7979, in lookup_qualified
+     raise KeyError(
+ KeyError: "Could not find builtin symbol 'AwaitableGenerator' (If you are running a test case, use a fixture that defines this symbol)"
+ 

starlette (https://github.com/encode/starlette)
+ .../projects/_starlette_venv/lib/python3.13/site-packages/trio/_core/_traps.py:65: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 2.3.0
+ .../projects/_starlette_venv/lib/python3.13/site-packages/trio/_core/_traps.py:65: note: use --pdb to drop into pdb
- starlette/testclient.py:92: error: Unused "type: ignore" comment  [unused-ignore]
- starlette/testclient.py:93: error: Class cannot subclass "Response" (has type "Any")  [misc]
- starlette/testclient.py:137: error: Incompatible types in assignment (expression has type "tuple[MemoryObjectSendStream[MutableMapping[str, Any]], MemoryObjectReceiveStream[MutableMapping[str, Any]]]", variable has type "create_memory_object_stream[MutableMapping[str, Any]]")  [assignment]
- starlette/testclient.py:139: error: Incompatible types in assignment (expression has type "tuple[MemoryObjectSendStream[MutableMapping[str, Any]], MemoryObjectReceiveStream[MutableMapping[str, Any]]]", variable has type "create_memory_object_stream[MutableMapping[str, Any]]")  [assignment]
- starlette/testclient.py:163: error: Unexpected keyword argument "status_code" for "WebSocketDenialResponse"  [call-arg]
- starlette/testclient.py:163: note: "WebSocketDenialResponse" defined in "starlette.websockets"
- starlette/testclient.py:163: error: Unexpected keyword argument "headers" for "WebSocketDenialResponse"  [call-arg]
- starlette/testclient.py:163: error: Unexpected keyword argument "content" for "WebSocketDenialResponse"  [call-arg]
- starlette/testclient.py:207: error: Class cannot subclass "BaseTransport" (has type "Any")  [misc]
- starlette/testclient.py:371: error: Unused "type: ignore" comment  [unused-ignore]
- starlette/testclient.py:373: error: Unused "type: ignore" comment  [unused-ignore]
- starlette/testclient.py:377: error: Class cannot subclass "Client" (has type "Any")  [misc]
- starlette/testclient.py:430: error: Unused "type: ignore" comment  [unused-ignore]
- starlette/testclient.py:471: error: Unused "type: ignore" comment  [unused-ignore]
- starlette/testclient.py:494: error: Unused "type: ignore" comment  [unused-ignore]
- starlette/testclient.py:517: error: Unused "type: ignore" comment  [unused-ignore]
- starlette/testclient.py:540: error: Unused "type: ignore" comment  [unused-ignore]
- starlette/testclient.py:571: error: Unused "type: ignore" comment  [unused-ignore]
- starlette/testclient.py:602: error: Unused "type: ignore" comment  [unused-ignore]
- starlette/testclient.py:633: error: Unused "type: ignore" comment  [unused-ignore]
- starlette/testclient.py:688: error: Incompatible types in assignment (expression has type "tuple[MemoryObjectSendStream[MutableMapping[str, Any] | None], MemoryObjectReceiveStream[MutableMapping[str, Any] | None]]", variable has type "create_memory_object_stream[MutableMapping[str, Any] | None]")  [assignment]
- starlette/testclient.py:690: error: Incompatible types in assignment (expression has type "tuple[MemoryObjectSendStream[MutableMapping[str, Any]], MemoryObjectReceiveStream[MutableMapping[str, Any]]]", variable has type "create_memory_object_stream[MutableMapping[str, Any]]")  [assignment]
- starlette/middleware/base.py:189: error: Incompatible types in assignment (expression has type "tuple[MemoryObjectSendStream[MutableMapping[str, Any]], MemoryObjectReceiveStream[MutableMapping[str, Any]]]", variable has type "create_memory_object_stream[MutableMapping[str, Any]]")  [assignment]
- tests/test_testclient.py:268: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_testclient.py:269: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_templates.py:33: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_templates.py:34: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_templates.py:73: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_templates.py:74: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_templates.py:99: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_templates.py:100: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_templates.py:129: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_templates.py:130: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_templates.py:134: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_templates.py:135: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_templates.py:175: error: Unused "type: ignore" comment  [unused-ignore]
- tests/test_templates.py:176: error: Unused "type: ignore" comment  [unused-ignore]
+ Traceback (most recent call last):
+   File "mypy/checker.py", line 765, in accept
+   File "mypy/nodes.py", line 1358, in accept
+   File "mypy/checker.py", line 5757, in visit_decorator
+     self.visit_decorator_inner(e)
+   File "mypy/checker.py", line 5778, in visit_decorator_inner
+     ret_type = self.named_generic_type("typing.AwaitableGenerator", [ty, tc, tr, t])
+   File "mypy/checker.py", line 7889, in named_generic_type
+     info = self.lookup_typeinfo(name)
+   File "mypy/checker.py", line 7896, in lookup_typeinfo
+     sym = self.lookup_qualified(fullname)
+   File "mypy/checker.py", line 7979, in lookup_qualified
+     raise KeyError(
+ KeyError: "Could not find builtin symbol 'AwaitableGenerator' (If you are running a test case, use a fixture that defines this symbol)"
+ 

websockets (https://github.com/aaugustin/websockets)
+ .../projects/_websockets_venv/lib/python3.13/site-packages/trio/_core/_traps.py:65: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 2.3.0
+ .../projects/_websockets_venv/lib/python3.13/site-packages/trio/_core/_traps.py:65: note: use --pdb to drop into pdb
+ Traceback (most recent call last):
+   File "mypy/checker.py", line 765, in accept
+   File "mypy/nodes.py", line 1358, in accept
+   File "mypy/checker.py", line 5757, in visit_decorator
+     self.visit_decorator_inner(e)
+   File "mypy/checker.py", line 5778, in visit_decorator_inner
+     ret_type = self.named_generic_type("typing.AwaitableGenerator", [ty, tc, tr, t])
+   File "mypy/checker.py", line 7889, in named_generic_type
+     info = self.lookup_typeinfo(name)
+   File "mypy/checker.py", line 7896, in lookup_typeinfo
+     sym = self.lookup_qualified(fullname)
+   File "mypy/checker.py", line 7979, in lookup_qualified
+     raise KeyError(
+ KeyError: "Could not find builtin symbol 'AwaitableGenerator' (If you are running a test case, use a fixture that defines this symbol)"
+ 

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.

1 participant