https://gcc.gnu.org/g:d7bb10b894601757925f95029904b73a2bfe9a46

commit d7bb10b894601757925f95029904b73a2bfe9a46
Author: Eric Gallager <egalla...@gcc.gnu.org>
Date:   Wed Aug 28 03:30:01 2024 -0400

    run `ruff check --fix --unsafe-fixes`

Diff:
---
 contrib/analyze_brprob.py                          | 31 +++++++++++++---------
 contrib/check_GNU_style_lib.py                     | 26 +++++++++---------
 contrib/dg-extract-results.py                      |  2 --
 contrib/header-tools/headerutils.py                |  7 +++--
 contrib/testsuite-management/validate_failures.py  |  4 +--
 contrib/update-copyright.py                        |  1 -
 gcc/gdbhooks.py                                    |  2 +-
 gcc/regenerate-opt-urls.py                         |  1 -
 .../diagnostic-test-paths-multithreaded-sarif.py   |  2 +-
 .../gcc.dg/sarif-output/test-include-chain-1.py    |  2 +-
 .../gcc.dg/sarif-output/test-include-chain-2.py    |  2 +-
 .../gcc.dg/sarif-output/test-missing-semicolon.py  |  2 +-
 .../gcc.dg/sarif-output/test-no-diagnostics.py     |  2 +-
 gcc/testsuite/gcc.dg/sarif-output/test-werror.py   |  2 +-
 14 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/contrib/analyze_brprob.py b/contrib/analyze_brprob.py
index 17b8865ac6a7..5073ab65b2ed 100755
--- a/contrib/analyze_brprob.py
+++ b/contrib/analyze_brprob.py
@@ -111,16 +111,16 @@ class PredictDefFile:
             elif l == '':
                 p = None
 
-            if p != None:
+            if p is not None:
                 heuristic = [x for x in heuristics if x.name == p]
                 heuristic = heuristic[0] if len(heuristic) == 1 else None
 
                 m = re.match('.*HITRATE \(([^)]*)\).*', l)
-                if (m != None):
+                if (m is not None):
                     self.predictors[p] = int(m.group(1))
 
                     # modify the line
-                    if heuristic != None:
+                    if heuristic is not None:
                         new_line = (l[:m.start(1)]
                             + str(round(heuristic.get_hitrate()))
                             + l[m.end(1):])
@@ -181,14 +181,14 @@ class Summary:
     def print(self, branches_max, count_max, predict_def):
         # filter out most hot edges (if requested)
         self.edges = sorted(self.edges, reverse = True, key = lambda x: 
x.count)
-        if args.coverage_threshold != None:
+        if args.coverage_threshold is not None:
             threshold = args.coverage_threshold * self.count() / 100
             edges = [x for x in self.edges if x.count < threshold]
             if len(edges) != 0:
                 self.edges = edges
 
         predicted_as = None
-        if predict_def != None and self.name in predict_def.predictors:
+        if predict_def is not None and self.name in predict_def.predictors:
             predicted_as = predict_def.predictors[self.name]
 
         print('%-40s %8i %5.1f%% %11.2f%% %7.2f%% / %6.2f%% %14i %8s %5.1f%%' %
@@ -200,14 +200,14 @@ class Summary:
                 self.count(), self.count_formatted(),
                 percentage(self.count(), count_max)), end = '')
 
-        if predicted_as != None:
+        if predicted_as is not None:
             print('%12i%% %5.1f%%' % (predicted_as,
                 self.get_hitrate() - predicted_as), end = '')
         else:
             print(' ' * 20, end = '')
 
         # print details about the most important edges
-        if args.coverage_threshold == None:
+        if args.coverage_threshold is None:
             edges = [x for x in self.edges[:100] if x.count * hot_threshold > 
self.count()]
             if args.verbose:
                 for c in edges:
@@ -251,15 +251,20 @@ class Profile:
         count_max = self.count_max()
         branches_max = self.branches_max()
 
-        sorter = lambda x: x.branches()
+        def sorter(x):
+            return x.branches()
         if sorting == 'branch-hitrate':
-            sorter = lambda x: x.get_branch_hitrate()
+            def sorter(x):
+                return x.get_branch_hitrate()
         elif sorting == 'hitrate':
-            sorter = lambda x: x.get_hitrate()
+            def sorter(x):
+                return x.get_hitrate()
         elif sorting == 'coverage':
-            sorter = lambda x: x.count
+            def sorter(x):
+                return x.count
         elif sorting == 'name':
-            sorter = lambda x: x.name.lower()
+            def sorter(x):
+                return x.name.lower()
 
         print('%-40s %8s %6s %12s %18s %14s %8s %6s %12s %6s %s' %
             ('HEURISTICS', 'BRANCHES', '(REL)',
@@ -275,7 +280,7 @@ class Profile:
             return
 
         predict_def = None
-        if args.def_file != None:
+        if args.def_file is not None:
             predict_def = PredictDefFile(args.def_file)
             predict_def.parse_and_modify(heuristics, args.write_def_file)
 
diff --git a/contrib/check_GNU_style_lib.py b/contrib/check_GNU_style_lib.py
index 07a33ce6fca4..ee63cb3aa9e4 100755
--- a/contrib/check_GNU_style_lib.py
+++ b/contrib/check_GNU_style_lib.py
@@ -119,7 +119,7 @@ class TrailingWhitespaceCheck:
     def check(self, filename, lineno, line):
         assert(len(line) == 0 or line[-1] != '\n')
         m = self.re.search(line)
-        if m != None:
+        if m is not None:
             return CheckError(filename, lineno,
                 line[:m.start(1)] + error_string(ws_char * len(m.group(1)))
                 + line[m.end(1):],
@@ -131,7 +131,7 @@ class SentenceSeparatorCheck:
 
     def check(self, filename, lineno, line):
         m = self.re.search(line)
-        if m != None:
+        if m is not None:
             return CheckError(filename, lineno,
                 line[:m.start(1)] + error_string(ws_char * len(m.group(1)))
                 + line[m.end(1):],
@@ -143,7 +143,7 @@ class SentenceEndOfCommentCheck:
 
     def check(self, filename, lineno, line):
         m = self.re.search(line)
-        if m != None:
+        if m is not None:
             return CheckError(filename, lineno,
                 line[:m.start(1)] + error_string(ws_char * len(m.group(1)))
                 + line[m.end(1):],
@@ -155,7 +155,7 @@ class SentenceDotEndCheck:
 
     def check(self, filename, lineno, line):
         m = self.re.search(line)
-        if m != None:
+        if m is not None:
             return CheckError(filename, lineno,
                 line[:m.start(1)] + error_string(m.group(1)) + line[m.end(1):],
                 'dot, space, space, end of comment', m.start(1))
@@ -170,7 +170,7 @@ class FunctionParenthesisCheck:
             return None
 
         m = self.re.search(line)
-        if m != None:
+        if m is not None:
             return CheckError(filename, lineno,
                 line[:m.start(2)] + error_string(m.group(2)) + line[m.end(2):],
                 'there should be exactly one space between function name ' \
@@ -185,7 +185,7 @@ class SquareBracketCheck:
             return None
 
         m = self.re.search(line)
-        if m != None:
+        if m is not None:
             return CheckError(filename, lineno,
                 line[:m.start(1)] + error_string(m.group(1)) + line[m.end(1):],
                 'there should be no space before a left square bracket',
@@ -197,7 +197,7 @@ class ClosingParenthesisCheck:
 
     def check(self, filename, lineno, line):
         m = self.re.search(line)
-        if m != None:
+        if m is not None:
             return CheckError(filename, lineno,
                 line[:m.start(1)] + error_string(m.group(1)) + line[m.end(1):],
                 'there should be no space before closing parenthesis',
@@ -211,7 +211,7 @@ class BracesOnSeparateLineCheck:
 
     def check(self, filename, lineno, line):
         m = self.re.search(line)
-        if m != None:
+        if m is not None:
             return CheckError(filename, lineno,
                 line[:m.start(2)] + error_string(m.group(2)) + line[m.end(2):],
                 'braces should be on a separate line', m.start(2))
@@ -223,7 +223,7 @@ class TrailinigOperatorCheck:
 
     def check(self, filename, lineno, line):
         m = self.re.search(line)
-        if m != None:
+        if m is not None:
             return CheckError(filename, lineno,
                 line[:m.start(1)] + error_string(m.group(1)) + line[m.end(1):],
                 'trailing operator', m.start(1))
@@ -284,17 +284,17 @@ def check_GNU_style_file(file, format):
             continue
 
         for hunk in pfile:
-            delta = 0
             for line in hunk:
-                if line.is_added and line.target_line_no != None:
+                if line.is_added and line.target_line_no is not None:
                     for check in checks:
                         line_chomp = line.value.replace('\n', '')
                         e = check.check(t, line.target_line_no, line_chomp)
-                        if e != None:
+                        if e is not None:
                             errors.append(e)
 
     if format == 'stdio':
-        fn = lambda x: x.error_message
+        def fn(x):
+            return x.error_message
         i = 1
         for (k, errors) in groupby(sorted(errors, key = fn), fn):
             errors = list(errors)
diff --git a/contrib/dg-extract-results.py b/contrib/dg-extract-results.py
index 0fe3c5f15199..00d1d5c66d26 100644
--- a/contrib/dg-extract-results.py
+++ b/contrib/dg-extract-results.py
@@ -238,7 +238,6 @@ class Prog:
     # 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
@@ -405,7 +404,6 @@ class Prog:
     # Parse a .log or .sum file.
     def parse_file (self, filename, file):
         tool = None
-        target = None
         num_variations = 1
         while True:
             line = file.readline()
diff --git a/contrib/header-tools/headerutils.py 
b/contrib/header-tools/headerutils.py
index d62a79bd2733..3b8e0ee1a63f 100755
--- a/contrib/header-tools/headerutils.py
+++ b/contrib/header-tools/headerutils.py
@@ -397,7 +397,7 @@ def find_replace_include (find, replace, src):
     inc = find_pound_include (line, True, True)
     if inc == find:
       for y in replace:
-        if seen.get(y) == None:
+        if seen.get(y) is None:
           res.append("#include \""+y+"\"\n")
           seen[y] = True
           if y != find:
@@ -407,7 +407,7 @@ def find_replace_include (find, replace, src):
         anything = True
     else:
       if inc in replace:
-        if seen.get(inc) == None:
+        if seen.get(inc) is None:
           res.append (line)
           seen[inc] = True
       else:
@@ -512,10 +512,9 @@ def spawn_makes (command_list):
 
 def get_make_output_parallel (targ_list, make_opt, at_a_time):
   command = list()
-  targname = list()
   if at_a_time == 0:
     at_a_time = multiprocessing.cpu_count() * 2
-  proc_res = [0] * at_a_time
+  [0] * at_a_time
   for x in targ_list:
     if make_opt[-2:] == ".o":
       s = "cd " + x[1] + "/gcc/; make " + make_opt
diff --git a/contrib/testsuite-management/validate_failures.py 
b/contrib/testsuite-management/validate_failures.py
index f81ac4f135d2..3658fab9095c 100755
--- a/contrib/testsuite-management/validate_failures.py
+++ b/contrib/testsuite-management/validate_failures.py
@@ -143,7 +143,7 @@ class TestResult(object):
               file=sys.stderr)
         raise
       self.ordinal = ordinal
-      if tool == None or exp == None:
+      if tool is None or exp is None:
         # .sum file seem to be broken.  There was no "tool" and/or "exp"
         # lines preceding this result.
         print(f'.sum file seems to be broken: tool="{tool}", exp="{exp}", 
summary_line="{summary_line}"',
@@ -458,7 +458,7 @@ def CollectSumFiles(builddir):
 
 def GetResults(sum_files, build_results = None):
   """Collect all the test results from the given .sum files."""
-  if build_results == None:
+  if build_results is None:
     build_results = ResultSet()
   for sum_fname in sum_files:
     if _OPTIONS.verbosity >= 3:
diff --git a/contrib/update-copyright.py b/contrib/update-copyright.py
index 5df00a33d771..0334285309f3 100755
--- a/contrib/update-copyright.py
+++ b/contrib/update-copyright.py
@@ -410,7 +410,6 @@ class Copyright:
         mode = None
         encoding = self.guess_encoding(pathname)
         with open (pathname, 'r', encoding=encoding) as file:
-            prev = None
             mode = os.fstat (file.fileno()).st_mode
             for line in file:
                 while line:
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index 7a64c03b8acb..ab4508116bf0 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -690,7 +690,7 @@ class BreakOnPass(gdb.Command):
 
     def invoke(self, arg, from_tty):
         sym = '(anonymous namespace)::%s::execute' % arg
-        breakpoint = gdb.Breakpoint(sym)
+        gdb.Breakpoint(sym)
 
 BreakOnPass()
 
diff --git a/gcc/regenerate-opt-urls.py b/gcc/regenerate-opt-urls.py
index c47e7b115c68..5efb6fcf738c 100755
--- a/gcc/regenerate-opt-urls.py
+++ b/gcc/regenerate-opt-urls.py
@@ -219,7 +219,6 @@ TARGET_SPECIFIC_PAGES = {
     'gcc/AArch64-Options.html' : 'gcc/config/aarch64/',
     'gcc/AMD-GCN-Options.html' : 'gcc/config/gcn/',
     'gcc/ARC-Options.html' : 'gcc/config/arc/',
-    'gcc/ARC-Options.html' : 'gcc/config/arc/',
     'gcc/ARM-Options.html' : 'gcc/config/arm/',
     'gcc/AVR-Options.html' : 'gcc/config/avr/',
     'gcc/Adapteva-Epiphany-Options.html' : 'gcc/config/epiphany/',
diff --git 
a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-multithreaded-sarif.py 
b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-multithreaded-sarif.py
index cb00faf1532a..7cf859174441 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-multithreaded-sarif.py
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-multithreaded-sarif.py
@@ -59,7 +59,7 @@ def test_execution_successful(sarif):
     invocation = invocations[0]
 
     # We expect a mere 'warning' to allow executionSuccessful be true
-    assert invocation['executionSuccessful'] == True
+    assert invocation['executionSuccessful'] is True
 
 def test_result(sarif):
     runs = sarif['runs']
diff --git a/gcc/testsuite/gcc.dg/sarif-output/test-include-chain-1.py 
b/gcc/testsuite/gcc.dg/sarif-output/test-include-chain-1.py
index 4bb2ebf61473..8e8f5ab4c49f 100644
--- a/gcc/testsuite/gcc.dg/sarif-output/test-include-chain-1.py
+++ b/gcc/testsuite/gcc.dg/sarif-output/test-include-chain-1.py
@@ -22,7 +22,7 @@ def test_execution_unsuccessful(sarif):
     invocation = invocations[0]
 
     # We expect the errors to make executionSuccessful be false
-    assert invocation['executionSuccessful'] == False
+    assert invocation['executionSuccessful'] is False
 
 def test_location_relationships(sarif):
     runs = sarif['runs']
diff --git a/gcc/testsuite/gcc.dg/sarif-output/test-include-chain-2.py 
b/gcc/testsuite/gcc.dg/sarif-output/test-include-chain-2.py
index 761fe1b59a9c..d4ccc05bf4ef 100644
--- a/gcc/testsuite/gcc.dg/sarif-output/test-include-chain-2.py
+++ b/gcc/testsuite/gcc.dg/sarif-output/test-include-chain-2.py
@@ -40,7 +40,7 @@ def test_execution_successful(sarif):
     invocation = invocations[0]
 
     # We expect a mere 'warning' to allow executionSuccessful be true
-    assert invocation['executionSuccessful'] == True
+    assert invocation['executionSuccessful'] is True
 
 def test_result(sarif):
     runs = sarif['runs']
diff --git a/gcc/testsuite/gcc.dg/sarif-output/test-missing-semicolon.py 
b/gcc/testsuite/gcc.dg/sarif-output/test-missing-semicolon.py
index 17759d35a468..17353083a404 100644
--- a/gcc/testsuite/gcc.dg/sarif-output/test-missing-semicolon.py
+++ b/gcc/testsuite/gcc.dg/sarif-output/test-missing-semicolon.py
@@ -22,7 +22,7 @@ def test_execution_unsuccessful(sarif):
     invocation = invocations[0]
 
     # We expect the 'error' to make executionSuccessful be false
-    assert invocation['executionSuccessful'] == False
+    assert invocation['executionSuccessful'] is False
 
 def test_location_relationships(sarif):
     runs = sarif['runs']
diff --git a/gcc/testsuite/gcc.dg/sarif-output/test-no-diagnostics.py 
b/gcc/testsuite/gcc.dg/sarif-output/test-no-diagnostics.py
index f5812df17dc0..88e573a923ae 100644
--- a/gcc/testsuite/gcc.dg/sarif-output/test-no-diagnostics.py
+++ b/gcc/testsuite/gcc.dg/sarif-output/test-no-diagnostics.py
@@ -21,7 +21,7 @@ def test_execution_successful(sarif):
     assert len(invocations) == 1
     invocation = invocations[0]
 
-    assert invocation['executionSuccessful'] == True
+    assert invocation['executionSuccessful'] is True
     assert invocation['toolExecutionNotifications'] == []
 
 def test_empty_results(sarif):
diff --git a/gcc/testsuite/gcc.dg/sarif-output/test-werror.py 
b/gcc/testsuite/gcc.dg/sarif-output/test-werror.py
index 99c2c2c97919..a888f7d756ea 100644
--- a/gcc/testsuite/gcc.dg/sarif-output/test-werror.py
+++ b/gcc/testsuite/gcc.dg/sarif-output/test-werror.py
@@ -24,7 +24,7 @@ def test_execution_unsuccessful(sarif):
     assert '-Werror=unused-variable' in invocation['arguments']
 
     # We expect the 'Werror' to make executionSuccessful be false
-    assert invocation['executionSuccessful'] == False
+    assert invocation['executionSuccessful'] is False
 
 def test_result(sarif):
     runs = sarif['runs']

Reply via email to