Skip to content

Commit 9430628

Browse files
committed
Fix remote debugging stubtest issues
1 parent 427d712 commit 9430628

2 files changed

Lines changed: 52 additions & 3 deletions

File tree

stdlib/_remote_debugging.pyi

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from _typeshed import StrOrBytesPath, structseq
22
from collections.abc import Callable, Sequence
3-
from typing import Final, Self, TypeAlias, final
3+
from typing import Final, TypeAlias, final
4+
from typing_extensions import Self, disjoint_base
45

56
_Location: TypeAlias = int | LocationInfo | None
67
_Frame: TypeAlias = tuple[str, _Location, str, int | None] | FrameInfo
@@ -17,6 +18,7 @@ THREAD_STATUS_UNKNOWN: Final[int]
1718

1819
@final
1920
class LocationInfo(structseq[int], tuple[int, int, int, int]):
21+
__match_args__: Final = ("lineno", "end_lineno", "col_offset", "end_col_offset")
2022
@property
2123
def lineno(self) -> int: ...
2224
@property
@@ -28,6 +30,7 @@ class LocationInfo(structseq[int], tuple[int, int, int, int]):
2830

2931
@final
3032
class FrameInfo(structseq[object], tuple[str, _Location, str, int | None]):
33+
__match_args__: Final = ("filename", "location", "funcname", "opcode")
3134
@property
3235
def filename(self) -> str: ...
3336
@property
@@ -39,13 +42,15 @@ class FrameInfo(structseq[object], tuple[str, _Location, str, int | None]):
3942

4043
@final
4144
class CoroInfo(structseq[object], tuple[list[_Frame], int | str]):
45+
__match_args__: Final = ("call_stack", "task_name")
4246
@property
4347
def call_stack(self) -> list[_Frame]: ...
4448
@property
4549
def task_name(self) -> int | str: ...
4650

4751
@final
4852
class TaskInfo(structseq[object], tuple[int, str, list[CoroInfo], list[CoroInfo]]):
53+
__match_args__: Final = ("task_id", "task_name", "coroutine_stack", "awaited_by")
4954
@property
5055
def task_id(self) -> int: ...
5156
@property
@@ -57,6 +62,7 @@ class TaskInfo(structseq[object], tuple[int, str, list[CoroInfo], list[CoroInfo]
5762

5863
@final
5964
class ThreadInfo(structseq[object], tuple[int, int, list[_Frame]]):
65+
__match_args__: Final = ("thread_id", "status", "frame_info")
6066
@property
6167
def thread_id(self) -> int: ...
6268
@property
@@ -66,20 +72,34 @@ class ThreadInfo(structseq[object], tuple[int, int, list[_Frame]]):
6672

6773
@final
6874
class InterpreterInfo(structseq[object], tuple[int, list[ThreadInfo]]):
75+
__match_args__: Final = ("interpreter_id", "threads")
6976
@property
7077
def interpreter_id(self) -> int: ...
7178
@property
7279
def threads(self) -> list[ThreadInfo]: ...
7380

7481
@final
7582
class AwaitedInfo(structseq[object], tuple[int, list[TaskInfo]]):
83+
__match_args__: Final = ("thread_id", "awaited_by")
7684
@property
7785
def thread_id(self) -> int: ...
7886
@property
7987
def awaited_by(self) -> list[TaskInfo]: ...
8088

8189
@final
8290
class GCStatsInfo(structseq[object], tuple[int, int, int, int, int, int, int, int, int, float]):
91+
__match_args__: Final = (
92+
"gen",
93+
"iid",
94+
"ts_start",
95+
"ts_stop",
96+
"collections",
97+
"collected",
98+
"uncollectable",
99+
"candidates",
100+
"heap_size",
101+
"duration",
102+
)
83103
@property
84104
def gen(self) -> int: ...
85105
@property
@@ -101,6 +121,8 @@ class GCStatsInfo(structseq[object], tuple[int, int, int, int, int, int, int, in
101121
@property
102122
def duration(self) -> float: ...
103123

124+
@final
125+
@disjoint_base
104126
class RemoteUnwinder:
105127
def __init__(
106128
self,
@@ -121,10 +143,14 @@ class RemoteUnwinder:
121143
def pause_threads(self) -> bool: ...
122144
def resume_threads(self) -> bool: ...
123145

146+
@final
147+
@disjoint_base
124148
class GCMonitor:
125149
def __init__(self, pid: int, *, debug: bool = False) -> None: ...
126150
def get_gc_stats(self, all_interpreters: bool = False) -> list[GCStatsInfo]: ...
127151

152+
@final
153+
@disjoint_base
128154
class BinaryWriter:
129155
total_samples: int
130156
def __init__(
@@ -137,6 +163,8 @@ class BinaryWriter:
137163
def __exit__(self, exc_type: object = None, exc_val: object = None, exc_tb: object = None) -> bool: ...
138164
def get_stats(self) -> _Stats: ...
139165

166+
@final
167+
@disjoint_base
140168
class BinaryReader:
141169
sample_count: int
142170
sample_interval_us: int

stdlib/asyncio/tools.pyi

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
11
import sys
22
from collections.abc import Iterable
33
from enum import Enum
4-
from typing import SupportsIndex
4+
from typing import NamedTuple, SupportsIndex, type_check_only
55

6-
from _remote_debugging import AwaitedInfo as _AwaitedInfo
6+
@type_check_only
7+
class _AwaitedInfo(NamedTuple): # AwaitedInfo_Type from _remote_debugging
8+
thread_id: int
9+
awaited_by: list[_TaskInfo]
10+
11+
@type_check_only
12+
class _TaskInfo(NamedTuple): # TaskInfo_Type from _remote_debugging
13+
task_id: int
14+
task_name: str
15+
coroutine_stack: list[_CoroInfo]
16+
awaited_by: list[_CoroInfo]
17+
18+
@type_check_only
19+
class _CoroInfo(NamedTuple): # CoroInfo_Type from _remote_debugging
20+
call_stack: list[_FrameInfo]
21+
task_name: int | str
22+
23+
@type_check_only
24+
class _FrameInfo(NamedTuple): # FrameInfo_Type from _remote_debugging
25+
filename: str
26+
lineno: int
27+
funcname: str
728

829
class NodeType(Enum):
930
COROUTINE = 1

0 commit comments

Comments
 (0)