mirror of
https://github.com/microsoft/debugpy.git
synced 2025-12-23 08:48:12 +00:00
Fix type annotations
This commit is contained in:
parent
c4fdc79936
commit
b2c0b3e106
5 changed files with 20 additions and 14 deletions
|
|
@ -3,6 +3,10 @@
|
|||
# for license information.
|
||||
|
||||
import itertools
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import debugpy.server.adapters as adapters
|
||||
|
||||
# Unique IDs for DAP objects such as threads, variables, breakpoints etc. These are
|
||||
# negative to allow for pre-existing OS-assigned IDs (which are positive) to be used
|
||||
|
|
@ -10,12 +14,12 @@ import itertools
|
|||
_dap_ids = itertools.count(-1, -1)
|
||||
|
||||
|
||||
def new_dap_id():
|
||||
def new_dap_id() -> int:
|
||||
"""Returns the next unique ID."""
|
||||
return next(_dap_ids)
|
||||
|
||||
|
||||
def adapter():
|
||||
def adapter() -> Optional["adapters.Adapter"]:
|
||||
"""
|
||||
Returns the instance of Adapter corresponding to the debug adapter that is currently
|
||||
connected to this process, or None if there is no adapter connected. Use in lieu of
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
Object inspection: rendering values, enumerating children etc.
|
||||
"""
|
||||
|
||||
from typing import Iterable
|
||||
from collections.abc import Iterable
|
||||
|
||||
|
||||
class ChildObject:
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
"""Object inspection for builtin Python types."""
|
||||
|
||||
from collections.abc import Iterable
|
||||
from itertools import count
|
||||
from typing import Iterable
|
||||
|
||||
from debugpy.common import log
|
||||
from debugpy.server.inspect import ChildObject, ObjectInspector, inspect
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import re
|
|||
import threading
|
||||
import traceback
|
||||
from collections import defaultdict
|
||||
from collections.abc import Callable, Iterable
|
||||
from dataclasses import dataclass
|
||||
from debugpy import server
|
||||
from debugpy.common import log
|
||||
|
|
@ -15,7 +16,7 @@ from enum import Enum
|
|||
from pathlib import Path
|
||||
from sys import monitoring
|
||||
from types import CodeType, FrameType
|
||||
from typing import Callable, ClassVar, Dict, Iterable, List, Literal, Union
|
||||
from typing import ClassVar, Literal, Union
|
||||
|
||||
# Shared for all global state pertaining to breakpoints and stepping.
|
||||
_cvar = threading.Condition()
|
||||
|
|
@ -145,7 +146,7 @@ class Thread:
|
|||
can exclude a specific thread from tracing.
|
||||
"""
|
||||
|
||||
_all: ClassVar[Dict[int, "Thread"]] = {}
|
||||
_all: ClassVar[dict[int, "Thread"]] = {}
|
||||
|
||||
def __init__(self, python_thread: threading.Thread):
|
||||
"""
|
||||
|
|
@ -294,9 +295,9 @@ class StackFrame:
|
|||
python_frame: FrameType
|
||||
|
||||
_source: Source | None
|
||||
_scopes: List[Scope]
|
||||
_scopes: list[Scope]
|
||||
|
||||
_all: ClassVar[Dict[int, "StackFrame"]] = {}
|
||||
_all: ClassVar[dict[int, "StackFrame"]] = {}
|
||||
|
||||
def __init__(self, thread: Thread, python_frame: FrameType):
|
||||
"""
|
||||
|
|
@ -351,7 +352,7 @@ class StackFrame:
|
|||
def get(self, id: int) -> "StackFrame":
|
||||
return self._all.get(id, None)
|
||||
|
||||
def scopes(self) -> List[Scope]:
|
||||
def scopes(self) -> list[Scope]:
|
||||
if self._scopes is None:
|
||||
self._scopes = [
|
||||
Scope(self, "local", self.python_frame.f_locals),
|
||||
|
|
@ -554,9 +555,9 @@ class Breakpoint:
|
|||
hit_count: int
|
||||
"""Number of times this breakpoint has been hit."""
|
||||
|
||||
_all: ClassVar[Dict[int, "Breakpoint"]] = {}
|
||||
_all: ClassVar[dict[int, "Breakpoint"]] = {}
|
||||
|
||||
_at: ClassVar[Dict[Source, Dict[int, List["Breakpoint"]]]] = defaultdict(
|
||||
_at: ClassVar[dict[Source, dict[int, list["Breakpoint"]]]] = defaultdict(
|
||||
lambda: defaultdict(lambda: [])
|
||||
)
|
||||
|
||||
|
|
@ -594,7 +595,7 @@ class Breakpoint:
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def at(self, source: Source, line: int) -> List["Breakpoint"]:
|
||||
def at(self, source: Source, line: int) -> list["Breakpoint"]:
|
||||
"""
|
||||
Returns a list of all breakpoints at the specified location.
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import inspect
|
|||
import sys
|
||||
import threading
|
||||
import traceback
|
||||
from collections.abc import Iterable
|
||||
from debugpy import server
|
||||
from debugpy.server.tracing import (
|
||||
Breakpoint,
|
||||
|
|
@ -21,7 +22,7 @@ from debugpy.server.tracing import (
|
|||
)
|
||||
from sys import monitoring
|
||||
from types import CodeType, FrameType, TracebackType
|
||||
from typing import Iterable, Literal, Type
|
||||
from typing import Literal
|
||||
|
||||
|
||||
class Log:
|
||||
|
|
@ -442,7 +443,7 @@ class Tracer:
|
|||
self._process_exception(exc, thread, "reraise")
|
||||
|
||||
def _sys_excepthook(
|
||||
self, exc_type: Type, exc: BaseException, tb: TracebackType
|
||||
self, exc_type: type, exc: BaseException, tb: TracebackType
|
||||
):
|
||||
thread = self._this_thread()
|
||||
if thread is None or not thread.is_traced:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue