[llvm] fix(cross-project-tests/**.py): fix comparison to None (PR #94016)
Eisuke Kawashima via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 29 06:26:37 PST 2024
https://github.com/e-kwsm updated https://github.com/llvm/llvm-project/pull/94016
>From ea086bdb019dca7e307af00eff6d8520799961f7 Mon Sep 17 00:00:00 2001
From: Eisuke Kawashima <e-kwsm at users.noreply.github.com>
Date: Sat, 11 May 2024 23:57:11 +0900
Subject: [PATCH] fix(cross-project-tests/**.py): fix comparison to None
from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations):
> Comparisons to singletons like None should always be done with is or
> is not, never the equality operators.
---
.../debuginfo-tests/dexter/dex/command/ParseCommand.py | 2 +-
.../dex/debugger/DebuggerControllers/ConditionalController.py | 4 ++--
.../dex/debugger/DebuggerControllers/ControllerHelpers.py | 2 +-
.../debuginfo-tests/dexter/dex/debugger/Debuggers.py | 2 +-
.../dexter/dex/debugger/visualstudio/VisualStudio.py | 2 +-
.../debuginfo-tests/dexter/dex/tools/test/Tool.py | 2 +-
cross-project-tests/lit.cfg.py | 2 +-
7 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py b/cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py
index 29d7867e808673..4b086e14d40500 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/command/ParseCommand.py
@@ -98,7 +98,7 @@ def _build_command(
def label_to_line(label_name: str) -> int:
line = labels.get(label_name, None)
- if line != None:
+ if line is not None:
return line
raise format_unresolved_label_err(label_name, raw_text, path.base, lineno)
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ConditionalController.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ConditionalController.py
index a7d6b570b55e89..ac3054c3a0edfc 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ConditionalController.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ConditionalController.py
@@ -62,7 +62,7 @@ def __init__(
self.finish_on_remove = finish_on_remove
def has_conditions(self):
- return self.expression != None
+ return self.expression is not None
def get_conditional_expression_list(self):
conditional_list = []
@@ -76,7 +76,7 @@ def add_hit(self):
self.current_hit_count += 1
def should_be_removed(self):
- if self.max_hit_count == None:
+ if self.max_hit_count is None:
return False
return self.current_hit_count >= self.max_hit_count
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ControllerHelpers.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ControllerHelpers.py
index 3e5a7b919d7032..a4ca5ae0158e99 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ControllerHelpers.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/DebuggerControllers/ControllerHelpers.py
@@ -39,7 +39,7 @@ def update_step_watches(step_info, watches, commands):
for watch in towatch:
loc = step_info.current_location
if (
- loc.path != None
+ loc.path is not None
and os.path.exists(loc.path)
and os.path.samefile(watch.path, loc.path)
and have_hit_line(watch, loc)
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py
index 1b0d4d5871cbeb..67b715af786985 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/Debuggers.py
@@ -183,7 +183,7 @@ def handle_debugger_tool_options(context, defaults): # noqa
if options.debugger == "lldb":
_warn_meaningless_option(context, "--show-debugger")
- if options.source_root_dir != None:
+ if options.source_root_dir is not None:
if not os.path.isabs(options.source_root_dir):
raise ToolArgumentError(
f'<d>--source-root-dir: expected absolute path, got</> <r>"{options.source_root_dir}"</>'
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py
index a6752274efac20..a7f12cde1f047b 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/debugger/visualstudio/VisualStudio.py
@@ -256,7 +256,7 @@ def delete_breakpoints(self, ids):
for bp in self._debugger.Breakpoints:
# We're looking at the user-set breakpoints so there should be no
# Parent.
- assert bp.Parent == None
+ assert bp.Parent is None
this_vsbp = VSBreakpoint(
PurePath(bp.File), bp.FileLine, bp.FileColumn, bp.Condition
)
diff --git a/cross-project-tests/debuginfo-tests/dexter/dex/tools/test/Tool.py b/cross-project-tests/debuginfo-tests/dexter/dex/tools/test/Tool.py
index f07641041254ba..c366062cec7a92 100644
--- a/cross-project-tests/debuginfo-tests/dexter/dex/tools/test/Tool.py
+++ b/cross-project-tests/debuginfo-tests/dexter/dex/tools/test/Tool.py
@@ -150,7 +150,7 @@ def _get_results_path(self, test_name):
"""Returns the path to the test results directory for the test denoted
by test_name.
"""
- assert self.context.options.results_directory != None
+ assert self.context.options.results_directory is not None
return os.path.join(
self.context.options.results_directory,
self._get_results_basename(test_name),
diff --git a/cross-project-tests/lit.cfg.py b/cross-project-tests/lit.cfg.py
index 9935fe6a199da8..c2a8bcef26cbfc 100644
--- a/cross-project-tests/lit.cfg.py
+++ b/cross-project-tests/lit.cfg.py
@@ -51,7 +51,7 @@
def get_required_attr(config, attr_name):
attr_value = getattr(config, attr_name, None)
- if attr_value == None:
+ if attr_value is None:
lit_config.fatal(
"No attribute %r in test configuration! You may need to run "
"tests from your build directory or add this attribute "
More information about the llvm-commits
mailing list