Skip to content

Commit 08de180

Browse files
committed
Misc pylint, isort and black stuff
1 parent d8ff821 commit 08de180

10 files changed

Lines changed: 59 additions & 48 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ clean:
6565

6666
#: Create source (tarball) and binary (egg) distribution
6767
dist: check-rst
68-
bash ./admin-tools/make-dist.sh
68+
bash ./admin-tools/make-dist-newer.sh
6969

7070
#: Create source tarball
7171
sdist: check-rst

trepan/bwcli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: iso-8859-1 -*-
3-
# Copyright (C) 2013, 2015, 2020 Rocky Bernstein <rocky@gnu.org>
3+
# Copyright (C) 2013, 2015, 2020, 2023 Rocky Bernstein <rocky@gnu.org>
44
#
55
# This program is free software: you can redistribute it and/or modify
66
# it under the terms of the GNU General Public License as published by
@@ -16,12 +16,12 @@
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
""" The hairy command-line interface to the debugger.
1818
"""
19-
import os, os.path as osp, sys
19+
import os.path as osp
20+
import pyficache
21+
import sys
2022

2123
from optparse import OptionParser
2224

23-
from pyficache import resolve_name_to_path
24-
2525
# Our local modules
2626
from trepan import clifns as Mclifns
2727
from trepan import debugger as Mdebugger, exception as Mexcept, misc as Mmisc
@@ -31,8 +31,8 @@
3131
# The name of the debugger we are currently going by.
3232
__title__ = "trepan"
3333

34-
# VERSION.py sets variable VERSION.
35-
from trepan.VERSION import VERSION as __version__
34+
# version.py sets variable __version__
35+
from trepan.version import __version__
3636

3737

3838
def process_options(debugger_name, pkg_version, sys_argv, option_list=None):

trepan/lib/sighandler.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2009, 2013-2014, 2016, 2022 Rocky Bernstein <rocky@gnu.org>
2+
# Copyright (C) 2009, 2013-2014, 2016, 2022, 2023 Rocky Bernstein <rocky@gnu.org>
33
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
@@ -22,8 +22,10 @@
2222
#
2323
import signal
2424

25+
from typing import Optional
2526

26-
def yes_or_no(b):
27+
28+
def yes_or_no(b) -> str:
2729
"""Return 'Yes' for True and 'No' for False, and ?? for anything
2830
else."""
2931
if type(b) != bool:
@@ -33,7 +35,7 @@ def yes_or_no(b):
3335
return "No"
3436

3537

36-
def lookup_signame(num):
38+
def lookup_signame(num: int) -> Optional[str]:
3739
"""Find the corresponding signal name for 'num'. Return None
3840
if 'num' is invalid."""
3941
signames = signal.__dict__
@@ -57,10 +59,10 @@ def lookup_signum(name):
5759
if hasattr(signal, uname):
5860
return getattr(signal, uname)
5961
return None
60-
return # Not reached
62+
return # noqa
6163

6264

63-
def canonic_signame(name_num):
65+
def canonic_signame(name_num) -> Optional[str]:
6466
"""Return a signal name for a signal name or signal
6567
number. Return None is name_num is an int but not a valid signal
6668
number and False if name_num is a not number. If name_num is a
@@ -211,7 +213,7 @@ def __init__(self, dbgr, ignore_list=None, default_print=True):
211213
self.action("SIGINT stop print nostack nopass")
212214
return
213215

214-
def initialize_handler(self, signame):
216+
def initialize_handler(self, signame: str):
215217
if signame in fatal_signals:
216218
return False
217219
signum = lookup_signum(signame)
@@ -253,13 +255,13 @@ def initialize_handler(self, signame):
253255
pass
254256
return True
255257

256-
def set_signal_replacement(self, signum, handle):
258+
def set_signal_replacement(self, signum: int, handle):
257259
"""A replacement for signal.signal which chains the signal behind
258260
the debugger's handler"""
259261
signame = lookup_signame(signum)
260262
if signame is None:
261263
self.dbgr.intf[-1].errmsg(
262-
("%s is not a signal number" " I know about.") % signum
264+
"%s is not a signal number I know about." % signum
263265
)
264266
return False
265267
# Since the intent is to set a handler, we should pass this
@@ -271,7 +273,7 @@ def set_signal_replacement(self, signum, handle):
271273
return True
272274
return False
273275

274-
def check_and_adjust_sighandler(self, signame, sigs):
276+
def check_and_adjust_sighandler(self, signame: str, sigs):
275277
"""
276278
Check to see if a single signal handler that we are interested
277279
in has changed or has not been set initially. On return

trepan/processor/command/info_subcmd/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2008-2009, 2014, 2018 Rocky Bernstein <rocky@gnu.org>
2+
#
3+
# Copyright (C) 2008-2009, 2014, 2018, 2023 Rocky Bernstein
4+
# <rocky@gnu.org>
35
#
46
# This program is free software: you can redistribute it and/or modify
57
# it under the terms of the GNU General Public License as published by
@@ -13,9 +15,10 @@
1315
#
1416
# You should have received a copy of the GNU General Public License
1517
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
""" Copyright (C) 2008, 2009, 2018 Rocky Bernstein <rocky@gnu.org> """
18+
""" Copyright (C) 2008, 2009, 2018, 2023 Rocky Bernstein <rocky@gnu.org> """
1719

18-
import glob, os
20+
import glob
21+
import os
1922

2023
# FIXME: Is it really helpful to "privatize" variable names below?
2124
# The below names are not part of the standard pre-defined names like

trepan/processor/command/info_subcmd/code.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2015 Rocky Bernstein <rocky@gnu.org>
2+
# Copyright (C) 2015, 2023 Rocky Bernstein <rocky@gnu.org>
33
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
@@ -14,11 +14,12 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
# Our local modules
18-
from trepan.processor.command import base_subcmd as Mbase_subcmd
1917
from trepan.lib import complete as Mcomplete
2018
from trepan.processor import frame as Mframe
2119

20+
# Our local modules
21+
from trepan.processor.command import base_subcmd as Mbase_subcmd
22+
2223

2324
class InfoCode(Mbase_subcmd.DebuggerSubcommand):
2425
"""**info code** [ *frame-number* | *pyton code object* ]
@@ -79,10 +80,10 @@ def run(self, args):
7980
return False
8081
frame = proc.stack[frame_num][0]
8182
code = frame.f_code
82-
except:
83+
except Exception:
8384
try:
8485
code = eval(args[0], frame.f_globals, frame.f_locals)
85-
except:
86+
except Exception:
8687
self.errmsg(
8788
"%s is not a evaluable as a code object or frame number."
8889
% args[0]
@@ -127,7 +128,7 @@ def run(self, args):
127128

128129

129130
if __name__ == "__main__":
130-
from trepan.processor.command import mock, info as Minfo
131+
from trepan.processor.command import info as Minfo, mock
131132

132133
d, cp = mock.dbg_setup()
133134
i = Minfo.InfoCommand(cp)

trepan/processor/command/info_subcmd/frame.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2015 Rocky Bernstein <rocky@gnu.org>
2+
# Copyright (C) 2015, 2023 Rocky Bernstein <rocky@gnu.org>
33
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
@@ -90,10 +90,10 @@ def run(self, args):
9090
)
9191
return False
9292
frame = proc.stack[frame_num][0]
93-
except:
93+
except Exception:
9494
try:
9595
frame = eval(args[0], frame.f_globals, frame.f_locals)
96-
except:
96+
except Exception:
9797
self.errmsg(
9898
"%s is not a evaluable as a frame object or frame number."
9999
% args[0]
@@ -107,7 +107,7 @@ def run(self, args):
107107

108108
mess = (
109109
"Frame %d" % Mframe.frame_num(proc, frame_num)
110-
if frame_num is not None
110+
if frame_num is not None and proc.stack is not None
111111
else "Frame Info"
112112
)
113113
self.section(mess)

trepan/processor/command/info_subcmd/line.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2008-2009, 2013, 2015, 2020 Rocky Bernstein <rocky@gnu.org>
2+
#
3+
# Copyright (C) 2008-2009, 2013, 2015, 2020, 2023 Rocky Bernstein
4+
# <rocky@gnu.org>
35
#
46
# This program is free software: you can redistribute it and/or modify
57
# it under the terms of the GNU General Public License as published by
@@ -13,15 +15,18 @@
1315
#
1416
# You should have received a copy of the GNU General Public License
1517
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
import inspect, re
18+
import inspect
1719
import os.path as osp
20+
import re
21+
22+
from pyficache import code_line_info
1823

19-
# Our local modules
20-
from trepan.processor.command.base_subcmd import DebuggerSubcommand
2124
from trepan.clifns import search_file
2225
from trepan.misc import wrapped_lines
2326
from trepan.processor.cmdbreak import parse_break_cmd
24-
from pyficache import code_line_info
27+
28+
# Our local modules
29+
from trepan.processor.command.base_subcmd import DebuggerSubcommand
2530

2631

2732
def find_function(funcname, filename):
@@ -78,7 +83,7 @@ def lineinfo(self, arg):
7883
(func, filename, lineno, condition, offset) = parse_break_cmd(
7984
self.proc, ["info args"]
8085
)
81-
if filename != None and lineno != None:
86+
if filename is not None and lineno is not None:
8287
return lineno, filename
8388
else:
8489
return None, None
@@ -109,10 +114,7 @@ def run(self, args):
109114
pass
110115

111116
line_info = code_line_info(filename, line_number)
112-
msg1 = 'Line %d of "%s"' % (
113-
line_number,
114-
self.core.filename(filename),
115-
)
117+
msg1 = 'Line %d of "%s"' % (line_number, self.core.filename(filename),)
116118
if line_info:
117119
msg2 = "starts at offset %d of %s and contains %d instructions" % (
118120
line_info[0].offsets[0],
@@ -142,9 +144,9 @@ def run(self, args):
142144

143145

144146
if __name__ == "__main__":
147+
from trepan.debugger import Trepan
145148
from trepan.processor.command import mock
146149
from trepan.processor.command.info import InfoCommand
147-
from trepan.debugger import Trepan
148150

149151
d = Trepan()
150152
d, cp = mock.dbg_setup(d)

trepan/processor/command/info_subcmd/locals.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2008-2009, 2013, 2015, 2018, 2020 Rocky Bernstein <rocky@gnu.org>
2+
#
3+
# Copyright (C) 2008-2009, 2013, 2015, 2018, 2020, 2023 Rocky
4+
# Bernstein <rocky@gnu.org>
35
#
46
# This program is free software: you can redistribute it and/or modify
57
# it under the terms of the GNU General Public License as published by
@@ -147,7 +149,6 @@ def run(self, args):
147149
d, cp = mock.dbg_setup(d)
148150
i = Minfo.InfoCommand(cp)
149151
sub = InfoLocals(i)
150-
l = list(range(30)) # Add a simple array to the local mix printed below.
151152
import inspect
152153

153154
cp.curframe = inspect.currentframe()

trepan/processor/command/info_subcmd/signals.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2009, 2015 Rocky Bernstein <rocky@gnu.org>
2+
# Copyright (C) 2009, 2015, 2023 Rocky Bernstein <rocky@gnu.org>
33
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
@@ -17,13 +17,12 @@
1717
# Our local modules
1818
from trepan.processor.command import base_subcmd as Mbase_subcmd
1919
from trepan.lib import complete as Mcomplete
20-
import columnize
2120

2221

2322
class InfoSignals(Mbase_subcmd.DebuggerSubcommand):
24-
"""**info signals** [*signal-name*]
23+
r"""**info signals** [*signal-name*]
2524
26-
**info signals** \*
25+
**info signals** *
2726
2827
Show information about how debugger treats signals to the program.
2928
Here are the boolean actions we can take:

trepan/processor/command/set_subcmd/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2008-2009, 2015, 2018, 2020 Rocky Bernstein <rocky@gnu.org>
2+
#
3+
# Copyright (C) 2008-2009, 2015, 2018, 2020, 2023 Rocky Bernstein
4+
# <rocky@gnu.org>
35
#
46
# This program is free software: you can redistribute it and/or modify
57
# it under the terms of the GNU General Public License as published by
@@ -13,7 +15,8 @@
1315
#
1416
# You should have received a copy of the GNU General Public License
1517
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
""" Copyright (C) 2008-2009, 2015, 2018, 2020 Rocky Bernstein <rocky@gnu.org> """
18+
"""Copyright (C) 2008-2009, 2015, 2018, 2020, 2023
19+
Rocky Bernstein <rocky@gnu.org>"""
1720

1821
import glob
1922
import os.path as osp

0 commit comments

Comments
 (0)