Skip to content

Commit 56a1924

Browse files
johnslavikCopilot
andcommitted
Remove unnecessary annotations from profiling stubs
Removed: - tracing/__main__.pyi: deleted — __main__ stubs are executable entry points, not importable API surface - tracing/_utils.pyi: deleted — _Utils is a private helper used only inside the tracing module itself - sampling/__main__.pyi: deleted — PERMISSION_ERROR constants and handle_permission_error are CLI implementation details, not importable API - sampling/binary_collector.pyi: removed COMPRESSION_NONE, COMPRESSION_ZSTD — internal constants not part of user-facing API - sampling/cli.pyi: removed CustomFormatter, DiffFlamegraphAction, FORMAT_EXTENSIONS, COLLECTOR_MAP, and associated imports — internal CLI scaffolding and dispatch dicts used only inside cli.py; also removed re-exports of errors/collectors/sample that duplicate their own modules - sampling/constants.pyi: removed MICROSECONDS_PER_SECOND (re-exported only internally), MILLISECONDS_PER_SECOND and _INTERNAL_FRAME_SUFFIXES (private implementation details) - sampling/gecko_collector.pyi: removed GECKO_CATEGORIES, CATEGORY_*, DEFAULT_SUBCATEGORY, GECKO_FORMAT_VERSION, GECKO_PREPROCESSED_VERSION, RESOURCE_TYPE_LIBRARY, FRAME_ADDRESS_NONE, FRAME_INLINE_DEPTH_ROOT, PROCESS_TYPE_MAIN, STACKWALK_DISABLED — integer constants that encode the internal Gecko profile format; not part of user-facing API - sampling/heatmap_collector.pyi: removed _TemplateLoader, _TreeBuilder, _HtmlRenderer — private classes (underscore-prefixed) used only internally for HTML rendering - sampling/opcode_utils.pyi: removed base_opcode, variant_opcode — these are local variables inside get_opcode_info, not module-level attributes; the stubs were incorrect - sampling/sample.pyi: removed MIN_SAMPLES_FOR_TUI — internal threshold constant for TUI display logic - sampling/_sync_coordinator.pyi: removed CoordinatorError, ArgumentError, SyncError, TargetError — all exceptions live in a private module (_sync_coordinator) and are only raised and caught internally; never exposed through any public module Kept despite `dead` flagging: - tracing/__init__.pyi: dump_stats, snapshot_stats, runcall — public methods on the exported Profile class; standard profiling API - sampling/binary_collector.pyi: get_stats, collect_failed_sample — public methods; collect_failed_sample is part of the Collector interface called in sample.py - sampling/binary_reader.pyi: get_stats, convert_binary_to_format — public method and public utility function - sampling/string_table.pyi: intern, get_string, get_strings — core API of StringTable - sampling/live_collector/display.pyi: get_dimensions, refresh, redraw, get_input, set_nodelay, has_colors, init_color_pair, get_color_pair, get_attr, find_text — abstract methods on DisplayInterface define the ABC contract; concrete implementations on CursesDisplay and MockDisplay must also be stubbed - sampling/live_collector/trend_tracker.pyi: set_enabled, get_trend — public methods on public class - sampling/live_collector/widgets.pyi: format_rate_with_units, draw_thread_status, draw_finished_banner, draw_stats_rows, render_filter_input_prompt — public methods on public widget classes - sampling/live_collector/collector.pyi: increment_status_flag, as_status_dict, collect_failed_sample — public methods on ThreadData dataclass and LiveStatsCollector Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5afdd54 commit 56a1924

File tree

11 files changed

+0
-113
lines changed

11 files changed

+0
-113
lines changed

stdlib/profiling/sampling/__main__.pyi

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
from typing import Never
22

3-
class CoordinatorError(Exception): ...
4-
class ArgumentError(CoordinatorError): ...
5-
class SyncError(CoordinatorError): ...
6-
class TargetError(CoordinatorError): ...
7-
83
def main() -> Never: ...

stdlib/profiling/sampling/binary_collector.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ from typing_extensions import Self
55

66
from .collector import Collector as Collector
77

8-
COMPRESSION_NONE: int
9-
COMPRESSION_ZSTD: int
10-
118
class BinaryCollector(Collector):
129
filename: str
1310
sample_interval_usec: int

stdlib/profiling/sampling/cli.pyi

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import argparse
2-
from collections.abc import Sequence
3-
from typing import Any
4-
51
from ._child_monitor import ChildProcessMonitor as ChildProcessMonitor
62
from .binary_collector import BinaryCollector as BinaryCollector
73
from .binary_reader import BinaryReader as BinaryReader
84
from .constants import (
9-
MICROSECONDS_PER_SECOND as MICROSECONDS_PER_SECOND,
105
PROFILING_MODE_ALL as PROFILING_MODE_ALL,
116
PROFILING_MODE_CPU as PROFILING_MODE_CPU,
127
PROFILING_MODE_EXCEPTION as PROFILING_MODE_EXCEPTION,
@@ -19,34 +14,5 @@ from .constants import (
1914
SORT_MODE_SAMPLE_PCT as SORT_MODE_SAMPLE_PCT,
2015
SORT_MODE_TOTTIME as SORT_MODE_TOTTIME,
2116
)
22-
from .errors import (
23-
SamplingModuleNotFoundError as SamplingModuleNotFoundError,
24-
SamplingScriptNotFoundError as SamplingScriptNotFoundError,
25-
SamplingUnknownProcessError as SamplingUnknownProcessError,
26-
)
27-
from .gecko_collector import GeckoCollector as GeckoCollector
28-
from .heatmap_collector import HeatmapCollector as HeatmapCollector
29-
from .live_collector import LiveStatsCollector as LiveStatsCollector
30-
from .pstats_collector import PstatsCollector as PstatsCollector
31-
from .sample import sample as sample, sample_live as sample_live
32-
from .stack_collector import (
33-
CollapsedStackCollector as CollapsedStackCollector,
34-
DiffFlamegraphCollector as DiffFlamegraphCollector,
35-
FlamegraphCollector as FlamegraphCollector,
36-
)
37-
38-
class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter): ...
39-
40-
class DiffFlamegraphAction(argparse.Action):
41-
def __call__(
42-
self,
43-
parser: argparse.ArgumentParser,
44-
namespace: argparse.Namespace,
45-
values: str | Sequence[Any] | None,
46-
option_string: str | None = None,
47-
) -> None: ...
48-
49-
FORMAT_EXTENSIONS: dict[str, str]
50-
COLLECTOR_MAP: dict[str, type[Any]]
5117

5218
def main() -> None: ...

stdlib/profiling/sampling/constants.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
MICROSECONDS_PER_SECOND: int
2-
MILLISECONDS_PER_SECOND: int
31
PROFILING_MODE_WALL: int
42
PROFILING_MODE_CPU: int
53
PROFILING_MODE_GIL: int
@@ -12,7 +10,6 @@ SORT_MODE_SAMPLE_PCT: int
1210
SORT_MODE_CUMUL_PCT: int
1311
SORT_MODE_NSAMPLES_CUMUL: int
1412
DEFAULT_LOCATION: tuple[int, int, int, int]
15-
_INTERNAL_FRAME_SUFFIXES: tuple[str, ...]
1613
THREAD_STATUS_HAS_GIL: int
1714
THREAD_STATUS_ON_CPU: int
1815
THREAD_STATUS_UNKNOWN: int

stdlib/profiling/sampling/gecko_collector.pyi

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,6 @@ from typing import Any
33
from .collector import Collector as Collector, filter_internal_frames as filter_internal_frames
44
from .opcode_utils import format_opcode as format_opcode, get_opcode_info as get_opcode_info
55

6-
GECKO_CATEGORIES: list[dict[str, Any]]
7-
CATEGORY_OTHER: int
8-
CATEGORY_PYTHON: int
9-
CATEGORY_NATIVE: int
10-
CATEGORY_GC: int
11-
CATEGORY_GIL: int
12-
CATEGORY_CPU: int
13-
CATEGORY_CODE_TYPE: int
14-
CATEGORY_OPCODES: int
15-
CATEGORY_EXCEPTION: int
16-
DEFAULT_SUBCATEGORY: int
17-
GECKO_FORMAT_VERSION: int
18-
GECKO_PREPROCESSED_VERSION: int
19-
RESOURCE_TYPE_LIBRARY: int
20-
FRAME_ADDRESS_NONE: int
21-
FRAME_INLINE_DEPTH_ROOT: int
22-
PROCESS_TYPE_MAIN: int
23-
STACKWALK_DISABLED: int
24-
256
class GeckoCollector(Collector):
267
sample_interval_usec: int
278
skip_idle: bool

stdlib/profiling/sampling/heatmap_collector.pyi

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,6 @@ class TreeNode:
3131
def get_python_path_info() -> dict[str, Any]: ...
3232
def extract_module_name(filename: str, path_info: dict[str, Any]) -> str: ...
3333

34-
class _TemplateLoader:
35-
index_template: str | None
36-
file_template: str | None
37-
index_css: str | None
38-
index_js: str | None
39-
file_css: str | None
40-
file_js: str | None
41-
logo_html: str | None
42-
def __init__(self) -> None: ...
43-
44-
class _TreeBuilder:
45-
@staticmethod
46-
def build_file_tree(file_stats: list[FileStats]) -> dict[str, TreeNode]: ...
47-
48-
class _HtmlRenderer:
49-
file_index: dict[str, str]
50-
heatmap_bar_height: int
51-
def __init__(self, file_index: dict[str, str]) -> None: ...
52-
def render_hierarchical_html(self, trees: dict[str, TreeNode]) -> str: ...
53-
5434
class HeatmapCollector(StackTraceCollector):
5535
FILE_INDEX_FORMAT: str
5636
line_samples: Counter[Any]
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
base_opcode: int | None
2-
variant_opcode: int | None
3-
41
def get_opcode_info(opcode_num: int) -> dict[str, str | bool]: ...
52
def format_opcode(opcode_num: int) -> str: ...
63
def get_opcode_mapping() -> dict[str, dict[int, str] | dict[int, int]]: ...

stdlib/profiling/sampling/sample.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ from .live_collector import LiveStatsCollector as LiveStatsCollector
1717
from .pstats_collector import PstatsCollector as PstatsCollector
1818
from .stack_collector import CollapsedStackCollector as CollapsedStackCollector, FlamegraphCollector as FlamegraphCollector
1919

20-
MIN_SAMPLES_FOR_TUI: int
21-
2220
class SampleProfiler:
2321
pid: int
2422
sample_interval_usec: int

stdlib/profiling/tracing/__main__.pyi

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)