Skip to content

Commit 075b8e0

Browse files
authored
Update stubtest for async and dunder pos only checking (#7333)
Co-authored-by: hauntsaninja <>
1 parent 3afc0b1 commit 075b8e0

File tree

9 files changed

+127
-7
lines changed

9 files changed

+127
-7
lines changed

.github/workflows/stubtest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
# - get_mypy_req in tests/stubtest_third_party.py
4040
# - stubtest-stdlib in .github/workflows/stubtest.yml
4141
# - stubtest-stdlib in .github/workflows/tests.yml
42-
run: pip install $(grep tomli== requirements-tests.txt) git+git://github.com/python/mypy@080bb0e04e9d5c4d2513621d1fb62f1d61a573e9
42+
run: pip install $(grep tomli== requirements-tests.txt) git+git://github.com/python/mypy@85fc99c99e7e2afc5896de1842d52e6e6cd55197
4343
- name: Run stubtest
4444
run: python tests/stubtest_stdlib.py
4545

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114
# - get_mypy_req in tests/stubtest_third_party.py
115115
# - stubtest-stdlib in .github/workflows/stubtest.yml
116116
# - stubtest-stdlib in .github/workflows/tests.yml
117-
run: pip install $(grep tomli== requirements-tests.txt) git+git://github.com/python/mypy@080bb0e04e9d5c4d2513621d1fb62f1d61a573e9
117+
run: pip install $(grep tomli== requirements-tests.txt) git+git://github.com/python/mypy@85fc99c99e7e2afc5896de1842d52e6e6cd55197
118118
- name: Run stubtest
119119
run: python tests/stubtest_stdlib.py
120120

stdlib/types.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,15 @@ class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]):
236236
__name__: str
237237
__qualname__: str
238238
def __aiter__(self) -> AsyncGeneratorType[_T_co, _T_contra]: ...
239-
async def __anext__(self) -> _T_co: ...
240-
async def asend(self, __val: _T_contra) -> _T_co: ...
239+
def __anext__(self) -> Coroutine[Any, Any, _T_co]: ...
240+
def asend(self, __val: _T_contra) -> Coroutine[Any, Any, _T_co]: ...
241241
@overload
242242
async def athrow(
243243
self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
244244
) -> _T_co: ...
245245
@overload
246246
async def athrow(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ...
247-
async def aclose(self) -> None: ...
247+
def aclose(self) -> Coroutine[Any, Any, None]: ...
248248
if sys.version_info >= (3, 9):
249249
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
250250

tests/stubtest_allowlists/darwin-py36.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,16 @@ ntpath.splitunc
99
posix.stat_float_times
1010
ssl.OP_ENABLE_MIDDLEBOX_COMPAT
1111
ssl.Options.OP_ENABLE_MIDDLEBOX_COMPAT
12-
1312
uuid.lib
13+
14+
# Not "async defs" at runtime
15+
asyncio.SelectorEventLoop.create_unix_connection
16+
asyncio.SelectorEventLoop.create_unix_server
17+
asyncio.open_unix_connection
18+
asyncio.start_unix_server
19+
asyncio.streams.open_unix_connection
20+
asyncio.streams.start_unix_server
21+
asyncio.unix_events.SelectorEventLoop.create_unix_connection
22+
asyncio.unix_events.SelectorEventLoop.create_unix_server
23+
asyncio.unix_events._UnixSelectorEventLoop.create_unix_connection
24+
asyncio.unix_events._UnixSelectorEventLoop.create_unix_server

tests/stubtest_allowlists/linux-py36.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,15 @@ posix.stat_float_times
1010
ssl.OP_ENABLE_MIDDLEBOX_COMPAT
1111
ssl.Options.OP_ENABLE_MIDDLEBOX_COMPAT
1212
uuid.lib
13+
14+
# Not "async defs" at runtime
15+
asyncio.SelectorEventLoop.create_unix_connection
16+
asyncio.SelectorEventLoop.create_unix_server
17+
asyncio.open_unix_connection
18+
asyncio.start_unix_server
19+
asyncio.streams.open_unix_connection
20+
asyncio.streams.start_unix_server
21+
asyncio.unix_events.SelectorEventLoop.create_unix_connection
22+
asyncio.unix_events.SelectorEventLoop.create_unix_server
23+
asyncio.unix_events._UnixSelectorEventLoop.create_unix_connection
24+
asyncio.unix_events._UnixSelectorEventLoop.create_unix_server

tests/stubtest_allowlists/py36.txt

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,93 @@ collections.Generator.gi_yieldfrom
103103
collections.Mapping.get # Adding None to the Union messed up mypy
104104
collections.Sequence.index # Supporting None in end is not mandatory
105105

106+
# Not "async def"s at runtime
107+
asyncio.AbstractEventLoop.connect_read_pipe
108+
asyncio.AbstractEventLoop.connect_write_pipe
109+
asyncio.AbstractEventLoop.create_datagram_endpoint
110+
asyncio.AbstractEventLoop.create_unix_connection
111+
asyncio.AbstractEventLoop.create_unix_server
112+
asyncio.AbstractEventLoop.getaddrinfo
113+
asyncio.AbstractEventLoop.getnameinfo
114+
asyncio.AbstractEventLoop.shutdown_asyncgens
115+
asyncio.AbstractEventLoop.subprocess_exec
116+
asyncio.AbstractEventLoop.subprocess_shell
117+
asyncio.AbstractServer.wait_closed
118+
asyncio.BaseEventLoop.connect_accepted_socket
119+
asyncio.BaseEventLoop.connect_read_pipe
120+
asyncio.BaseEventLoop.connect_write_pipe
121+
asyncio.BaseEventLoop.create_datagram_endpoint
122+
asyncio.BaseEventLoop.getaddrinfo
123+
asyncio.BaseEventLoop.getnameinfo
124+
asyncio.BaseEventLoop.shutdown_asyncgens
125+
asyncio.BaseEventLoop.subprocess_shell
126+
asyncio.Condition.wait
127+
asyncio.Condition.wait_for
128+
asyncio.Event.wait
129+
asyncio.Lock.acquire
130+
asyncio.Queue.get
131+
asyncio.Queue.join
132+
asyncio.Queue.put
133+
asyncio.Semaphore.acquire
134+
asyncio.StreamReader.__anext__
135+
asyncio.StreamReader.read
136+
asyncio.StreamReader.readexactly
137+
asyncio.StreamReader.readline
138+
asyncio.StreamReader.readuntil
139+
asyncio.StreamWriter.drain
140+
asyncio.create_subprocess_exec
141+
asyncio.create_subprocess_shell
142+
asyncio.open_connection
143+
asyncio.sleep
144+
asyncio.start_server
145+
asyncio.wait_for
146+
asyncio.base_events.BaseEventLoop.connect_accepted_socket
147+
asyncio.base_events.BaseEventLoop.connect_read_pipe
148+
asyncio.base_events.BaseEventLoop.connect_write_pipe
149+
asyncio.base_events.BaseEventLoop.create_datagram_endpoint
150+
asyncio.base_events.BaseEventLoop.getaddrinfo
151+
asyncio.base_events.BaseEventLoop.getnameinfo
152+
asyncio.base_events.BaseEventLoop.shutdown_asyncgens
153+
asyncio.base_events.BaseEventLoop.subprocess_shell
154+
asyncio.base_events.Server.wait_closed
155+
asyncio.base_subprocess.BaseSubprocessTransport._connect_pipes
156+
asyncio.base_subprocess.BaseSubprocessTransport._wait
157+
asyncio.events.AbstractEventLoop.connect_read_pipe
158+
asyncio.events.AbstractEventLoop.connect_write_pipe
159+
asyncio.events.AbstractEventLoop.create_datagram_endpoint
160+
asyncio.events.AbstractEventLoop.create_unix_connection
161+
asyncio.events.AbstractEventLoop.create_unix_server
162+
asyncio.events.AbstractEventLoop.getaddrinfo
163+
asyncio.events.AbstractEventLoop.getnameinfo
164+
asyncio.events.AbstractEventLoop.shutdown_asyncgens
165+
asyncio.events.AbstractEventLoop.subprocess_exec
166+
asyncio.events.AbstractEventLoop.subprocess_shell
167+
asyncio.events.AbstractServer.wait_closed
168+
asyncio.locks.Condition.wait
169+
asyncio.locks.Condition.wait_for
170+
asyncio.locks.Event.wait
171+
asyncio.locks.Lock.acquire
172+
asyncio.locks.Semaphore.acquire
173+
asyncio.locks._ContextManagerMixin.__aenter__
174+
asyncio.locks._ContextManagerMixin.__aexit__
175+
asyncio.queues.Queue.get
176+
asyncio.queues.Queue.join
177+
asyncio.queues.Queue.put
178+
asyncio.streams.StreamReader.__anext__
179+
asyncio.streams.StreamReader.read
180+
asyncio.streams.StreamReader.readexactly
181+
asyncio.streams.StreamReader.readline
182+
asyncio.streams.StreamReader.readuntil
183+
asyncio.streams.StreamWriter.drain
184+
asyncio.streams.open_connection
185+
asyncio.streams.start_server
186+
asyncio.subprocess.Process.communicate
187+
asyncio.subprocess.Process.wait
188+
asyncio.subprocess.create_subprocess_exec
189+
asyncio.subprocess.create_subprocess_shell
190+
asyncio.tasks.sleep
191+
asyncio.tasks.wait_for
192+
106193
# Exists at runtime, but missing from stubs
107194
_bisect.bisect
108195
_bisect.insort

tests/stubtest_allowlists/py37.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ _collections_abc.AsyncGenerator.ag_code
33
_collections_abc.AsyncGenerator.ag_frame
44
_collections_abc.AsyncGenerator.ag_running
55
_dummy_threading
6+
asyncio.AbstractEventLoop.run_in_executor # allowed to return a Future, changed in 3.8
7+
asyncio.events.AbstractEventLoop.run_in_executor
68
asyncio.Future.__init__ # Usually initialized from c object
79
asyncio.Future._callbacks # Usually initialized from c object
810
asyncio.futures.Future.__init__ # Usually initialized from c object

tests/stubtest_allowlists/win32-py36.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,11 @@ os.startfile
1818
# Exists at runtime, but missing from stubs
1919
asyncio.windows_utils.socketpair
2020
venv.EnvBuilder.include_binary
21+
22+
# Not "async defs" at runtime
23+
asyncio.IocpProactor.connect_pipe
24+
asyncio.ProactorEventLoop.create_pipe_connection
25+
asyncio.ProactorEventLoop.start_serving_pipe
26+
asyncio.windows_events.IocpProactor.connect_pipe
27+
asyncio.windows_events.ProactorEventLoop.create_pipe_connection
28+
asyncio.windows_events.ProactorEventLoop.start_serving_pipe

tests/stubtest_third_party.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_mypy_req():
2222
# - get_mypy_req in tests/stubtest_third_party.py
2323
# - stubtest-stdlib in .github/workflows/stubtest.yml
2424
# - stubtest-stdlib in .github/workflows/tests.yml
25-
return "git+git://github.com/python/mypy@080bb0e04e9d5c4d2513621d1fb62f1d61a573e9"
25+
return "git+git://github.com/python/mypy@85fc99c99e7e2afc5896de1842d52e6e6cd55197"
2626

2727
with open("requirements-tests.txt") as f:
2828
return next(line.strip() for line in f if "mypy" in line)

0 commit comments

Comments
 (0)