Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run python thru ruff check --fix --unsafe-fixes #79

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion git_hooks/gitlog2changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
elif re.search("Signed-off-by", line) >= 0:
continue
# Extract the actual commit message for this commit
elif authorFound & dateFound & messageFound == False:
elif authorFound & dateFound & messageFound is False:
# Find the commit message if we can
if len(line) == 1:
if messageNL:
Expand Down
2 changes: 0 additions & 2 deletions src/contrib/dg-extract-results.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ def parse_variations(self, filename, file):
# Parse from the first line after 'Running target ...' to the end
# of the run's summary.
def parse_run(self, filename, file, tool, variation, num_variations):
header = None
harness = None
segment = None
final_using = 0
Expand Down Expand Up @@ -413,7 +412,6 @@ def parse_final_summary(self, filename, file):
# Parse a .log or .sum file.
def parse_file(self, filename, file):
tool = None
target = None
num_variations = 1
while True:
line = file.readline()
Expand Down
1 change: 0 additions & 1 deletion src/etc/update-copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ def process_file(self, dir, filename, filter):
mode = None
encoding = self.guess_encoding(pathname)
with open(pathname, encoding=encoding) as file:
prev = None
mode = os.fstat(file.fileno()).st_mode
for line in file:
while line:
Expand Down
1 change: 0 additions & 1 deletion src/gdb/copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def may_have_copyright_notice(filename):
# For now, it may have a copyright notice if we find the word
# "Copyright" at the (reasonable) start of the given file, say
# 50 lines...
MAX_LINES = 50

fd = open(filename)

Expand Down
10 changes: 5 additions & 5 deletions src/gdb/python/lib/gdb/FrameDecorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def function(self):
# address. If GDB detects an integer value from this function
# it will attempt to find the function name from minimal
# symbols via its own internal functions.
if func == None:
if func is None:
pc = frame.pc()
return pc

Expand Down Expand Up @@ -266,7 +266,7 @@ def fetch_frame_locals(self):

block = self.frame.block()

while block != None:
while block is not None:
if block.is_global or block.is_static:
break
for sym in block:
Expand All @@ -286,12 +286,12 @@ def fetch_frame_args(self):

args = []
block = self.frame.block()
while block != None:
if block.function != None:
while block is not None:
if block.function is not None:
break
block = block.superblock

if block != None:
if block is not None:
for sym in block:
if not sym.is_argument:
continue
Expand Down
7 changes: 3 additions & 4 deletions src/gdb/python/lib/gdb/command/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ def explore_type(name, datatype, is_child):
print("'%s' is a %s with the following " "fields:\n" %
(name, type_desc))

has_explorable_fields = False
current_choice = 0
choice_to_compound_field_map = {}
print_list = []
Expand Down Expand Up @@ -710,7 +709,7 @@ def __init__(self):
super().__init__(name="explore", command_class=gdb.COMMAND_DATA, prefix=True)

def invoke(self, arg_str, from_tty):
if ExploreUtils.check_args("explore", arg_str) == False:
if ExploreUtils.check_args("explore", arg_str) is False:
return

# Check if it is a value
Expand Down Expand Up @@ -748,7 +747,7 @@ def __init__(self):
super().__init__(name="explore value", command_class=gdb.COMMAND_DATA)

def invoke(self, arg_str, from_tty):
if ExploreUtils.check_args("explore value", arg_str) == False:
if ExploreUtils.check_args("explore value", arg_str) is False:
return

value = ExploreUtils.get_value_from_str(arg_str)
Expand Down Expand Up @@ -779,7 +778,7 @@ def __init__(self):
super().__init__(name="explore type", command_class=gdb.COMMAND_DATA)

def invoke(self, arg_str, from_tty):
if ExploreUtils.check_args("explore type", arg_str) == False:
if ExploreUtils.check_args("explore type", arg_str) is False:
return

datatype = ExploreUtils.get_type_from_str(arg_str)
Expand Down
6 changes: 3 additions & 3 deletions src/gdb/python/lib/gdb/command/frame_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _complete_frame_filter_list(text, word, all_flag):
from text/word analysis. This list can be empty when there
are no suggestions for completion.
"""
if all_flag == True:
if all_flag is True:
filter_locations = ["all", "global", "progspace"]
else:
filter_locations = ["global", "progspace"]
Expand Down Expand Up @@ -378,7 +378,7 @@ def complete(self, text, word):

def invoke(self, arg, from_tty):
command_tuple = self._parse_pri_arg(arg)
if command_tuple != None:
if command_tuple is not None:
self._set_filter_priority(command_tuple)


Expand Down Expand Up @@ -457,7 +457,7 @@ def complete(self, text, word):

def invoke(self, arg, from_tty):
command_tuple = self._parse_pri_arg(arg)
if command_tuple == None:
if command_tuple is None:
return
filter_name = command_tuple[1]
list_name = command_tuple[0]
Expand Down
2 changes: 1 addition & 1 deletion src/gdb/python/lib/gdb/command/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_show_string(self, pvalue):
return "The extended prompt is not set."

def get_set_string(self):
if self.hook_set == False:
if self.hook_set is False:
gdb.prompt_hook = self.before_prompt_hook
self.hook_set = True
return ""
Expand Down
8 changes: 4 additions & 4 deletions src/gdb/python/lib/glib-2.0/glib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def read_global_var(symname):


def g_quark_to_string(quark):
if quark == None:
if quark is None:
return None
quark = int(quark)
if quark == 0:
Expand Down Expand Up @@ -109,7 +109,7 @@ def __iter__(self):
def __next__(self):
if self.ht == 0:
raise StopIteration
if self.value != None:
if self.value is not None:
v = self.value
self.value = None
return v
Expand Down Expand Up @@ -138,7 +138,7 @@ def __init__(self, val):
string_hash = None
if (
self.val != 0
and string_hash != None
and string_hash is not None
and self.val["hash_func"] == string_hash
):
self.keys_are_strings = True
Expand Down Expand Up @@ -181,7 +181,7 @@ def pretty_printer_lookup(val):


def register(obj):
if obj == None:
if obj is None:
obj = gdb

obj.pretty_printers.append(pretty_printer_lookup)
Expand Down
26 changes: 13 additions & 13 deletions src/gdb/python/lib/glib-2.0/gobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def lookup_fundamental_type(typenode):
if typenode == 0:
return None
val = read_global_var("static_fundamental_type_nodes")
if val == None:
if val is None:
return None
return val[typenode >> 2].address()

Expand All @@ -25,7 +25,7 @@ def lookup_fundamental_type(typenode):
gdb.lookup_type("TypeNode").pointer())
else:
typenode = lookup_fundamental_type(typenode)
if typenode != None:
if typenode is not None:
return glib.g_quark_to_string(typenode["qname"])
return None

Expand Down Expand Up @@ -89,7 +89,7 @@ def pretty_printer_lookup(val):


def get_signal_name(id):
if id == None:
if id is None:
return None
id = int(id)
if id == 0:
Expand Down Expand Up @@ -155,9 +155,9 @@ def name(self):
def read_var(self, frame, name, array=None):
try:
v = frame.read_var(name)
if v == None or v.is_optimized_out:
if v is None or v.is_optimized_out:
return None
if array != None:
if array is not None:
array.append(v)
return v
except ValueError:
Expand All @@ -166,20 +166,20 @@ def read_var(self, frame, name, array=None):
def read_object(self, frame, name, array=None):
try:
v = frame.read_var(name)
if v == None or v.is_optimized_out:
if v is None or v.is_optimized_out:
return None
v = v.cast(gdb.lookup_type("GObject").pointer())
# Ensure this is a somewhat correct object pointer
if v != None and g_type_name_from_instance(v):
if array != None:
if v is not None and g_type_name_from_instance(v):
if array is not None:
array.append(v)
return v
return None
except ValueError:
return None

def append(self, array, obj):
if obj != None:
if obj is not None:
array.append(obj)

def or_join_array(self, array):
Expand Down Expand Up @@ -209,7 +209,7 @@ def describe(self, stream, full):
signal = node["name"].string()
detail = self.read_var(frame, "detail")
detail = glib.g_quark_to_string(detail)
if detail != None:
if detail is not None:
signal = signal + ":" + detail
self.append(signals, signal)

Expand All @@ -226,7 +226,7 @@ def describe(self, stream, full):
if signal:
detail = self.read_var(frame, "detail")
detail = glib.g_quark_to_string(detail)
if detail != None:
if detail is not None:
signal = signal + ":" + detail
self.append(signals, signal)

Expand All @@ -237,7 +237,7 @@ def describe(self, stream, full):
if signal:
detail = self.read_var(frame, "detail")
detail = glib.g_quark_to_string(detail)
if detail != None:
if detail is not None:
signal = signal + ":" + detail
self.append(signals, signal)

Expand Down Expand Up @@ -321,7 +321,7 @@ def __next__(self):


def register(obj):
if obj == None:
if obj is None:
obj = gdb

gdb.backtrace.push_frame_filter(GFrameFilter)
Expand Down
4 changes: 2 additions & 2 deletions src/gdb/testsuite/gdb.base/pc-not-saved.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def __call__(self, pending_frame):
return None

block = gdb.block_for_pc(pc)
if block == None:
if block is None:
return None
func = block.function
if func == None:
if func is None:
return None
if str(func) != "break_bt_here":
return None
Expand Down
2 changes: 1 addition & 1 deletion src/gdb/testsuite/gdb.multi/multi-target-info-inferiors.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def inf_num(i):
# Print information about each inferior, and the connection it is
# using.
def info_inferiors():
all_inferiors = sorted(gdb.inferiors(), key=inf_num)
sorted(gdb.inferiors(), key=inf_num)
for i in gdb.inferiors():
print(
"Inferior %d, Connection #%d: %s"
Expand Down
7 changes: 5 additions & 2 deletions src/gdb/testsuite/gdb.perf/gmonster-null-lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ def warm_up(self):

def execute_test(self):
for run in self.run_names:
this_run_binfile = "%s-%s" % (self.binfile, utils.convert_spaces(run))
this_run_binfile = "%s-%s" % (self.binfile,
utils.convert_spaces(run))
utils.select_file(this_run_binfile)
utils.runto_main()
utils.safe_execute("mt expand-symtabs")
iteration = 5
while iteration > 0:
utils.safe_execute("mt flush-symbol-cache")
func = lambda: utils.safe_execute("p symbol_not_found")

def func():
return utils.safe_execute("p symbol_not_found")
self.measure.measure(func, run)
iteration -= 1
3 changes: 2 additions & 1 deletion src/gdb/testsuite/gdb.perf/gmonster-pervasive-typedef.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def func(self):

def execute_test(self):
for run in self.run_names:
self.this_run_binfile = "%s-%s" % (self.binfile, utils.convert_spaces(run))
self.this_run_binfile = "%s-%s" % (self.binfile,
utils.convert_spaces(run))
iteration = 5
while iteration > 0:
self.measure.measure(self.func, run)
Expand Down
7 changes: 5 additions & 2 deletions src/gdb/testsuite/gdb.perf/gmonster-print-cerr.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ def warm_up(self):

def execute_test(self):
for run in self.run_names:
this_run_binfile = "%s-%s" % (self.binfile, utils.convert_spaces(run))
this_run_binfile = "%s-%s" % (self.binfile,
utils.convert_spaces(run))
utils.select_file(this_run_binfile)
utils.runto_main()
iteration = 5
while iteration > 0:
utils.safe_execute("mt flush-symbol-cache")
func = lambda: utils.safe_execute("print gm_std::cerr")

def func():
return utils.safe_execute("print gm_std::cerr")
self.measure.measure(func, run)
iteration -= 1
11 changes: 8 additions & 3 deletions src/gdb/testsuite/gdb.perf/gmonster-ptype-string.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,19 @@ def warm_up(self):

def execute_test(self):
for run in self.run_names:
this_run_binfile = "%s-%s" % (self.binfile, utils.convert_spaces(run))
this_run_binfile = "%s-%s" % (self.binfile,
utils.convert_spaces(run))
utils.select_file(this_run_binfile)
utils.runto_main()
utils.safe_execute("mt expand-symtabs")
iteration = 5
while iteration > 0:
utils.safe_execute("mt flush-symbol-cache")
func1 = lambda: utils.safe_execute("ptype hello")
func = lambda: utils.run_n_times(2, func1)

def func1():
return utils.safe_execute("ptype hello")

def func():
return utils.run_n_times(2, func1)
self.measure.measure(func, run)
iteration -= 1
6 changes: 4 additions & 2 deletions src/gdb/testsuite/gdb.perf/gmonster-runto-main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ def warm_up(self):

def execute_test(self):
for run in self.run_names:
this_run_binfile = "%s-%s" % (self.binfile, utils.convert_spaces(run))
this_run_binfile = "%s-%s" % (self.binfile,
utils.convert_spaces(run))
utils.select_file(this_run_binfile)
iteration = 5
while iteration > 0:
func = lambda: utils.runto_main()
def func():
return utils.runto_main()
self.measure.measure(func, run)
iteration -= 1
Loading
Loading