Skip to content

Commit 1f9aafe

Browse files
committed
Some small lint
1 parent 521a850 commit 1f9aafe

3 files changed

Lines changed: 22 additions & 22 deletions

File tree

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
# General information about the project.
5858
project = "trepan3k"
59-
copyright = "2017, 2021 Rocky Bernstein"
59+
copyright = "2017, 2021, 2024 Rocky Bernstein"
6060
author = "Rocky Bernstein"
6161

6262
# The version info for the project you're documenting, acts as replacement for

trepan/lib/core.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import os.path as osp
3030
import sys
3131
import threading
32-
from typing import Any
32+
from typing import Any, Dict, NewType, Optional
3333

3434
# External packages
3535
import pyficache
@@ -44,18 +44,19 @@
4444
from trepan.processor.cmdproc import CommandProcessor
4545
from trepan.processor.trace import PrintProcessor
4646

47+
InitOptions = NewType("InitOptions", Dict[str, Any])
48+
49+
DEFAULT_INIT_OPTS: InitOptions = {
50+
"processor": None,
51+
# How many step events to skip before
52+
# entering event processor? Zero (0) means stop at the next one.
53+
# A negative number indicates no eventual stopping.
54+
"step_ignore": 0,
55+
"ignore_filter": None, # But see debugger.py
56+
}
4757

4858
class TrepanCore:
49-
DEFAULT_INIT_OPTS = {
50-
"processor": None,
51-
# How many step events to skip before
52-
# entering event processor? Zero (0) means stop at the next one.
53-
# A negative number indicates no eventual stopping.
54-
"step_ignore": 0,
55-
"ignore_filter": None, # But see debugger.py
56-
}
57-
58-
def __init__(self, debugger, opts=None):
59+
def __init__(self, debugger, opts: InitOptions=DEFAULT_INIT_OPTS):
5960
"""Create a debugger object. But depending on the value of
6061
key 'start' inside hash `opts', we may or may not initially
6162
start tracing events (i.e. enter the debugger).
@@ -64,7 +65,7 @@ def __init__(self, debugger, opts=None):
6465
"""
6566

6667
def get_option(key: str) -> Any:
67-
return option_set(opts, key, self.DEFAULT_INIT_OPTS)
68+
return option_set(opts, key, DEFAULT_INIT_OPTS)
6869

6970
self.bpmgr = BreakpointManager()
7071
self.current_bp = None
@@ -136,9 +137,10 @@ def get_option(key: str) -> Any:
136137

137138
return
138139

139-
def add_ignore(self, *frames_or_fns):
140+
def add_ignore(self, *frames_or_fns) -> Optional[Any]:
140141
"""Add `frame_or_fn' to the list of functions that are not to
141142
be debugged"""
143+
rc = None
142144
for frame_or_fn in frames_or_fns:
143145
rc = self.ignore_filter.add(frame_or_fn)
144146
pass
@@ -218,7 +220,7 @@ def remove_ignore(self, frame_or_fn):
218220
be debugged"""
219221
return self.ignore_filter.remove(frame_or_fn)
220222

221-
def start(self, opts=None):
223+
def start(self, opts: InitOptions=DEFAULT_INIT_OPTS):
222224
"""We've already created a debugger object, but here we start
223225
debugging in earnest. We can also turn off debugging (but have
224226
the hooks suspended or not) using 'stop'.
@@ -253,7 +255,7 @@ def get_option(key: str) -> Any:
253255
self.trace_hook_suspend = False
254256
return
255257

256-
def stop(self, options=None):
258+
def stop(self, options=DEFAULT_INIT_OPTS):
257259
# Our version of:
258260
# sys.settrace(None)
259261
try:
@@ -316,7 +318,6 @@ def is_break_here(self, frame):
316318
return True
317319
else:
318320
return False
319-
pass
320321
return False
321322

322323
def matches_condition(self, frame):
@@ -402,7 +403,7 @@ def set_next(self, frame, step_ignore=0, step_events=None):
402403
"""Sets to stop on the next event that happens in frame `frame`.
403404
an raises an exception return to a frame below `frame`
404405
"""
405-
self.step_events = None # Consider all events
406+
self.step_events = step_events
406407
self.stop_level = count_frames(frame)
407408
self.last_level = self.stop_level
408409
self.last_frame = frame
@@ -422,7 +423,7 @@ def trace_dispatch(self, frame, event: str, arg):
422423

423424
# Check to see if are in a call but we should be stepping over the call
424425
# using "next" of "finish". If so, then we can speed tracing by
425-
# removing futher tracing. Not though that we *also* must make sure
426+
# removing further tracing. Not though that we *also* must make sure
426427
# that we don't have any breakpoint set, since we have to check
427428
# for breakpoints in a kind of slow way of checking all events.
428429

@@ -499,7 +500,6 @@ def trace_dispatch(self, frame, event: str, arg):
499500
except Exception:
500501
pass
501502
pass
502-
pass
503503

504504
pass
505505

@@ -510,7 +510,7 @@ def trace_dispatch(self, frame, event: str, arg):
510510
class MockProcessor:
511511
pass
512512

513-
opts = {"processor": MockProcessor()}
513+
opts: InitOptions = {"processor": MockProcessor()}
514514
dc = TrepanCore(None, opts=opts)
515515
dc.step_ignore = 1
516516
print("dc._is_step_next_stop():", dc._is_step_next_stop("line"))

trepan/processor/location.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def resolve_address_location(proc, location) -> Optional[Location]:
219219
try:
220220
mod_or_func_or_code = eval(location.method, g, locals_dict)
221221
except Exception:
222-
split_names = location_method.split(".")
222+
split_names = location.method.split(".")
223223
if len(split_names) > 1:
224224
proc.msg(f'Try importing {".".join(split_names[:-1])}?')
225225
proc.errmsg(msg)

0 commit comments

Comments
 (0)