Skip to content

Update sys.monitoring for 3.14 #14288

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 38 additions & 26 deletions stdlib/sys/_monitoring.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,60 @@
# of being a `types.ModuleType` instance that cannot be directly imported,
# and exists in the `sys`-module namespace despite `sys` not being a package.

import sys
from collections.abc import Callable
from types import CodeType
from typing import Any
from typing import Any, Final, final
from typing_extensions import deprecated

DEBUGGER_ID: int
COVERAGE_ID: int
PROFILER_ID: int
OPTIMIZER_ID: int
DEBUGGER_ID: Final[int]
COVERAGE_ID: Final[int]
PROFILER_ID: Final[int]
OPTIMIZER_ID: Final[int]

def use_tool_id(tool_id: int, name: str, /) -> None: ...
def free_tool_id(tool_id: int, /) -> None: ...
def get_tool(tool_id: int, /) -> str | None: ...

events: _events
events: Final[_events]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Realistically not seeing why this shouldn't be final.


@final
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't really exist at runtime.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it use @type_check_only in that case?

class _events:
BRANCH: int
CALL: int
C_RAISE: int
C_RETURN: int
EXCEPTION_HANDLED: int
INSTRUCTION: int
JUMP: int
LINE: int
NO_EVENTS: int
PY_RESUME: int
PY_RETURN: int
PY_START: int
PY_THROW: int
PY_UNWIND: int
PY_YIELD: int
RAISE: int
RERAISE: int
STOP_ITERATION: int
CALL: Final[int]
C_RAISE: Final[int]
C_RETURN: Final[int]
EXCEPTION_HANDLED: Final[int]
INSTRUCTION: Final[int]
JUMP: Final[int]
LINE: Final[int]
NO_EVENTS: Final[int]
PY_RESUME: Final[int]
PY_RETURN: Final[int]
PY_START: Final[int]
PY_THROW: Final[int]
PY_UNWIND: Final[int]
PY_YIELD: Final[int]
RAISE: Final[int]
RERAISE: Final[int]
STOP_ITERATION: Final[int]
if sys.version_info >= (3, 14):
BRANCH_LEFT: Final[int]
BRANCH_TAKEN: Final[int]

@property
@deprecated("BRANCH is deprecated; use BRANCH_LEFT or BRANCH_TAKEN instead")
def BRANCH(self) -> int: ...

else:
BRANCH: Final[int]

def get_events(tool_id: int, /) -> int: ...
def set_events(tool_id: int, event_set: int, /) -> None: ...
def get_local_events(tool_id: int, code: CodeType, /) -> int: ...
def set_local_events(tool_id: int, code: CodeType, event_set: int, /) -> int: ...
def restart_events() -> None: ...

DISABLE: object
MISSING: object
DISABLE: Final[object]
MISSING: Final[object]

def register_callback(tool_id: int, event: int, func: Callable[..., Any] | None, /) -> Callable[..., Any] | None: ...