Fix some flake8 reports

This commit is contained in:
Tom Tromey
2023-11-22 21:16:00 -07:00
parent 233a39a424
commit 0c38b74cff
9 changed files with 23 additions and 50 deletions

2
.flake8 Normal file
View File

@@ -0,0 +1,2 @@
[flake8]
ignore = E501, W503

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2015, 2016 Tom Tromey <tom@tromey.com> # Copyright (C) 2015, 2016, 2023 Tom Tromey <tom@tromey.com>
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -15,8 +15,6 @@
# Adapt to gdb issues. # Adapt to gdb issues.
import gdb
import gui.params import gui.params
# The rule for adding a new entry here is that the bug must have some # The rule for adding a new entry here is that the bug must have some

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2012, 2013, 2015, 2016 Tom Tromey <tom@tromey.com> # Copyright (C) 2012, 2013, 2015, 2016, 2023 Tom Tromey <tom@tromey.com>
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -27,7 +27,6 @@ import gui.source
import gui.stack import gui.stack
import gui.startup import gui.startup
import gui.toplevel import gui.toplevel
from gui.startup import in_gtk_thread
class GuiCommand(gdb.Command): class GuiCommand(gdb.Command):
@@ -110,7 +109,7 @@ class GuiShowCommand(gdb.Command):
self.dont_repeat() self.dont_repeat()
try: try:
(symbol, ignore) = gdb.lookup_symbol(arg) (symbol, ignore) = gdb.lookup_symbol(arg)
except gdb.error as e: except gdb.error:
if gui.gdbutil.is_running(): if gui.gdbutil.is_running():
raise raise
symbol = gdb.lookup_global_symbol(arg) symbol = gdb.lookup_global_symbol(arg)
@@ -222,7 +221,6 @@ class GuiDprintfCommand(GuiPrintBase):
def invoke(self, arg, from_tty): def invoke(self, arg, from_tty):
(window, arg) = self._parse_arg(arg, False) (window, arg) = self._parse_arg(arg, False)
orig_arg = arg
(ignore, arg) = gdb.decode_line(arg) (ignore, arg) = gdb.decode_line(arg)
if arg is None: if arg is None:
raise gdb.GdbError("no printf arguments to 'gui dprintf'") raise gdb.GdbError("no printf arguments to 'gui dprintf'")
@@ -230,8 +228,8 @@ class GuiDprintfCommand(GuiPrintBase):
if not arg.startswith(","): if not arg.startswith(","):
raise gdb.GdbError("comma expected after linespec") raise gdb.GdbError("comma expected after linespec")
arg = arg[1:] arg = arg[1:]
spec = arg[0 : -len(arg)] spec = arg[0:-len(arg)]
DPrintfBreakpoint(spec, window, arg) gui.dprintf.DPrintfBreakpoint(spec, window, arg)
class GuiDisplayCommand(gdb.Command): class GuiDisplayCommand(gdb.Command):
@@ -309,6 +307,7 @@ DeleteWindowsCommand()
_can_override = False _can_override = False
# A temporary test to see if you have a gdb that supports this. # A temporary test to see if you have a gdb that supports this.
class TestCommand(gdb.Command): class TestCommand(gdb.Command):
"""A temporary test command created for the GUI. """A temporary test command created for the GUI.

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2013, 2015 Tom Tromey <tom@tromey.com> # Copyright (C) 2013, 2015, 2023 Tom Tromey <tom@tromey.com>
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -15,11 +15,10 @@
# Log window. # Log window.
import functools from difflib import Differ
from difflib import Differ, SequenceMatcher
import gdb import gdb
from gi.repository import Gtk, Pango from gi.repository import Pango
import gui.events import gui.events
import gui.startup import gui.startup

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2013, 2015 Tom Tromey <tom@tromey.com> # Copyright (C) 2013, 2015, 2023 Tom Tromey <tom@tromey.com>
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -13,8 +13,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import gdb
class _Event(object): class _Event(object):
def __init__(self): def __init__(self):

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2015 Tom Tromey <tom@tromey.com> # Copyright (C) 2015, 2023 Tom Tromey <tom@tromey.com>
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -37,6 +37,7 @@ def _prompt_window(attr):
gui_prompt_substitutions["W"] = _prompt_window gui_prompt_substitutions["W"] = _prompt_window
# GDB's API should do this... # GDB's API should do this...
def substitute_prompt_with_window(prompt, window): def substitute_prompt_with_window(prompt, window):
global _current_window_for_prompt global _current_window_for_prompt

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2013, 2015 Tom Tromey <tom@tromey.com> # Copyright (C) 2013, 2015, 2023 Tom Tromey <tom@tromey.com>
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -17,9 +17,6 @@
import functools import functools
import gdb
from gi.repository import Gtk, Pango
import gui.startup import gui.startup
import gui.toplevel import gui.toplevel
from gui.startup import in_gtk_thread from gui.startup import in_gtk_thread
@@ -47,12 +44,13 @@ class LogWindow(gui.toplevel.Toplevel):
self.view.modify_font(gui.params.font_manager.get_font()) self.view.modify_font(gui.params.font_manager.get_font())
self.buffer = builder.get_object("buffer") self.buffer = builder.get_object("buffer")
@in_gtk_thread # @in_gtk_thread
def set_font(self, font): # def set_font(self, font):
self.view.modify_font(Pango.FontDescription(font_name)) # self.view.modify_font(Pango.FontDescription(font_name))
@in_gtk_thread @in_gtk_thread
def deleted(self, *args): def deleted(self, *args):
global default_log_window
if default_log_window == self: if default_log_window == self:
default_log_window = None default_log_window = None
for window in gui.toplevel.state.windows(): for window in gui.toplevel.state.windows():

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2015 Tom Tromey <tom@tromey.com> # Copyright (C) 2015, 2023 Tom Tromey <tom@tromey.com>
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -74,7 +74,7 @@ class _StoredParameter(gdb.Parameter):
elif p_kind is gdb.PARAM_ZINTEGER: elif p_kind is gdb.PARAM_ZINTEGER:
val = storage.getint(self.storage_name) val = storage.getint(self.storage_name)
else: else:
raise Error("missing case in gdb gui code") raise gdb.error("missing case in gdb gui code")
# Don't record the first setting. # Don't record the first setting.
self.storage = None self.storage = None
if val is None: if val is None:
@@ -214,29 +214,6 @@ class _Missing(_StoredParameter):
return "Whether to warn about missing gdb features: " + v return "Whether to warn about missing gdb features: " + v
class _Lines(_StoredParameter):
# Silly gdb requirement.
""""""
set_doc = "Set whether to display line numbers in the source window."
show_doc = "Show whether to display line numbers in the source window."
def __init__(self):
super(_Lines, self).__init__(
"%s", "line-numbers", False, gdb.COMMAND_NONE, gdb.PARAM_BOOLEAN
)
@in_gdb_thread
def get_show_string(self, pvalue):
return "The current title format for the %s is: %s" % (self.name, self.value)
@in_gdb_thread
def get_set_string(self):
super(_Lines, self).get_set_string()
gui.toplevel.state.set_line_numbers(self.value)
return ""
class _Lines(_StoredParameter): class _Lines(_StoredParameter):
# Silly gdb requirement. # Silly gdb requirement.
"""""" """"""

View File

@@ -18,7 +18,7 @@
import os.path import os.path
import gdb import gdb
from gi.repository import Gdk, GdkPixbuf, GObject, Gtk, GtkSource, Pango from gi.repository import Gdk, GdkPixbuf, GObject, GtkSource
import gui import gui
import gui.bpcache import gui.bpcache
@@ -152,6 +152,7 @@ class BufferManager:
buffer_manager = BufferManager() buffer_manager = BufferManager()
# Return (FRAME, SYMTAB, FILE, LINE) for the selected frame, or, if # Return (FRAME, SYMTAB, FILE, LINE) for the selected frame, or, if
# there is no frame, for "main". # there is no frame, for "main".
@in_gdb_thread @in_gdb_thread