Skip to content

Commit 2966d54

Browse files
committed
linting ...
go over with flake8, isort and black
1 parent 901d515 commit 2966d54

70 files changed

Lines changed: 475 additions & 343 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ repos:
44
hooks:
55
- id: debug-statements
66
- id: end-of-file-fixer
7+
- repo: https://github.com/pycqa/isort
8+
rev: 5.10.1
9+
hooks:
10+
- id: isort
11+
stages: [commit]
712
- repo: https://github.com/psf/black
813
rev: 22.3.0
914
hooks:

__pkginfo__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
license = "GPL3"
9191
mailing_list = "python-debugger@googlegroups.com"
9292
modname = "trepan3k"
93-
py_modules = None
93+
py_modules = []
9494
short_desc = "GDB-like Python Debugger in the Trepan family"
9595

9696
import os.path as osp

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python3
22
import sys
33

4+
from setuptools import find_packages, setup
5+
46
SYS_VERSION = sys.version_info[0:2]
57
if not ((3, 1) <= SYS_VERSION <= (3, 10)):
68
mess = "Python Versions 3.1 to 3.10 are supported only in this package."
@@ -13,6 +15,7 @@
1315

1416
# Get the package information used in setup().
1517
from __pkginfo__ import (
18+
__version__,
1619
author,
1720
author_email,
1821
classifiers,
@@ -23,15 +26,12 @@
2326
modname,
2427
py_modules,
2528
short_desc,
26-
__version__,
2729
web,
2830
zip_safe,
2931
)
3032

3133
__import__("pkg_resources")
3234

33-
from setuptools import setup, find_packages
34-
3535
packages = find_packages()
3636

3737
setup(

trepan/__main__.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
# -*- coding: iso-8859-1 -*-
3-
# Copyright (C) 2008-2010, 2013-2018, 2020-2022 Rocky Bernstein
3+
# Copyright (C) 2008-2010, 2013-2018, 2020-2023 Rocky Bernstein
44
# <rocky@gnu.org>
55
#
66
# This program is free software: you can redistribute it and/or modify
@@ -17,8 +17,12 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
"""The command-line interface to the debugger.
1919
"""
20-
import os, pyficache, sys, tempfile
20+
import os
2121
import os.path as osp
22+
import sys
23+
import tempfile
24+
25+
import pyficache
2226

2327
package = "trepan"
2428

@@ -27,10 +31,10 @@
2731
import trepan.clifns as Mclifns
2832
import trepan.debugger as Mdebugger
2933
import trepan.exception as Mexcept
30-
import trepan.options as Moptions
3134
import trepan.interfaces.server as Mserver
3235
import trepan.lib.file as Mfile
3336
import trepan.misc as Mmisc
37+
import trepan.options as Moptions
3438

3539
# The name of the debugger we are currently going by.
3640
__title__ = package
@@ -107,11 +111,7 @@ def main(dbg=None, sys_argv=list(sys.argv)):
107111

108112
if Mfile.is_compiled_py(mainpyfile):
109113
try:
110-
from xdis import (
111-
load_module,
112-
PYTHON_VERSION_TRIPLE,
113-
IS_PYPY,
114-
)
114+
from xdis import IS_PYPY, PYTHON_VERSION_TRIPLE, load_module
115115
from xdis.version_info import version_tuple_to_str
116116

117117
(
@@ -256,7 +256,6 @@ def write_wrapper(*args, **kwargs):
256256
# pass
257257

258258
while True:
259-
260259
# Run the debugged script over and over again until we get it
261260
# right.
262261

trepan/bwprocessor/command/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
# """ Copyright (C) 2008, 2009, 2013 Rocky Bernstein <rocky@gnu.org> """
1414
__import__("pkg_resources").declare_namespace(__name__)
1515

16-
import glob, os
16+
import glob
17+
import os
1718

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

trepan/bwprocessor/command/quit.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
#
1212
# You should have received a copy of the GNU General Public License
1313
# along with this program. If not, see <http://www.gnu.org/licenses/>.
14-
import os, threading
14+
import os
15+
import threading
16+
17+
from trepan import exception as Mexcept
1518

1619
# Our local modules
1720
from trepan.bwprocessor.command import base_cmd as Mbase_cmd
18-
from trepan import exception as Mexcept
1921

2022

2123
class QuitCommand(Mbase_cmd.DebuggerCommand):

trepan/bwprocessor/location.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2015 Rocky Bernstein <rocky@gnu.org>
2+
# Copyright (C) 2015, 2023 Rocky Bernstein <rocky@gnu.org>
33
""" Location routines"""
44

5-
import pyficache, linecache, tempfile
5+
import linecache
6+
import tempfile
7+
8+
import pyficache
9+
610
from trepan.lib import stack as Mstack
711

812

trepan/bwprocessor/main.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2008-2010, 2013-2016 Rocky Bernstein <rocky@gnu.org>
2+
#
3+
# Copyright (C) 2008-2010, 2013-2016, 2023 Rocky Bernstein <rocky@gnu.org>
34
#
45
# This program is free software: you can redistribute it and/or modify
56
# it under the terms of the GNU General Public License as published by
@@ -13,15 +14,17 @@
1314
#
1415
# You should have received a copy of the GNU General Public License
1516
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
import inspect, linecache, sys, traceback
17-
import pyficache
17+
import inspect
18+
import linecache
19+
import sys
20+
import traceback
1821
from reprlib import Repr
1922

20-
from trepan import vprocessor as Mprocessor
21-
from trepan import exception as Mexcept, misc as Mmisc
22-
from trepan.lib import bytecode as Mbytecode, display as Mdisplay
23-
from trepan.lib import thred as Mthread
23+
import pyficache
24+
25+
from trepan import exception as Mexcept, misc as Mmisc, vprocessor as Mprocessor
2426
from trepan.bwprocessor import location as Mlocation, msg as Mmsg
27+
from trepan.lib import bytecode as Mbytecode, display as Mdisplay, thred as Mthread
2528

2629

2730
def get_stack(f, t, botframe, proc_obj=None):
@@ -224,7 +227,7 @@ def eval(self, arg):
224227
"""Eval string arg in the current frame context."""
225228
try:
226229
return eval(arg, self.curframe.f_globals, self.curframe.f_locals)
227-
except:
230+
except Exception:
228231
t, v = sys.exc_info()[:2]
229232
if isinstance(t, str):
230233
exc_type_name = t
@@ -249,7 +252,7 @@ def exec_line(self, line):
249252
try:
250253
code = compile(line + "\n", '"%s"' % line, "single")
251254
exec(code, global_vars, local_vars)
252-
except:
255+
except Exception:
253256
t, v = sys.exc_info()[:2]
254257
if isinstance(t, bytes):
255258
exc_type_name = t
@@ -265,7 +268,7 @@ def ok_for_running(self, cmd_obj, name, cmd_hash):
265268
if the command has the right number of arguments and so on.
266269
"""
267270
if hasattr(cmd_obj, "execution_set"):
268-
if not (self.core.execution_status in cmd_obj.execution_set):
271+
if self.core.execution_status not in cmd_obj.execution_set:
269272
part1 = "Command '%s' is not available for execution " "status:" % name
270273
Mmsg.errmsg(
271274
self,
@@ -357,7 +360,7 @@ def process_command(self):
357360
except (Mexcept.DebuggerQuit, Mexcept.DebuggerRestart, SystemExit):
358361
# Let these exceptions propagate through
359362
raise
360-
except:
363+
except Exception:
361364
Mmsg.errmsg(self, "INTERNAL ERROR: " + traceback.format_exc())
362365
pass
363366
pass
@@ -433,7 +436,7 @@ def _populate_commands(self):
433436
import_name = "command." + mod_name
434437
try:
435438
command_mod = getattr(__import__(import_name), mod_name)
436-
except:
439+
except Exception:
437440
print("Error importing %s: %s" % (mod_name, sys.exc_info()[0]))
438441
continue
439442

@@ -447,7 +450,7 @@ def _populate_commands(self):
447450
try:
448451
instance = eval(eval_cmd)
449452
cmd_instances.append(instance)
450-
except:
453+
except Exception:
451454
print(
452455
"Error loading %s from %s: %s"
453456
% (classname, mod_name, sys.exc_info()[0])

trepan/bwprocessor/msg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Copyright (C) 2015 Rocky Bernstein <rocky@gnu.org>
33
""" Common I/O routines"""
44

5+
56
# Note for errmsg, msg, and msg_nocr we don't want to simply make
67
# an assignment of method names like self.msg = self.debugger.intf.msg,
78
# because we want to allow the interface (intf) to change

trepan/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3-
# Copyright (C) 2009, 2013-2017, 2021 Rocky Bernstein
3+
#
4+
# Copyright (C) 2009, 2013-2017, 2021, 2023 Rocky Bernstein
45
#
56
# This program is free software; you can redistribute it and/or modify
67
# it under the terms of the GNU General Public License as published by
@@ -17,13 +18,12 @@
1718
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
1819
# 02110-1301 USA.
1920

20-
import sys, time
21+
import sys
22+
import time
23+
from optparse import OptionParser
2124

2225
# Our local modules
23-
from trepan.interfaces import client as Mclient
24-
from trepan.interfaces import comcodes as Mcomcodes
25-
26-
from optparse import OptionParser
26+
from trepan.interfaces import client as Mclient, comcodes as Mcomcodes
2727
from trepan.version import __version__
2828

2929

0 commit comments

Comments
 (0)