From ca92bdfa3ef8f9a1cc97167fc96601f8bd7b436b Mon Sep 17 00:00:00 2001 From: Eisuke Kawashima Date: Mon, 13 Jan 2025 21:03:04 +0900 Subject: [PATCH] [cross-project-tests] Use "is" instead of "==" to check for None (#94016) 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 29d7867e8086..4b086e14d405 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 a7d6b570b55e..ac3054c3a0ed 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 @@ class BreakpointRange: 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 @@ class BreakpointRange: 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 3e5a7b919d70..a4ca5ae0158e 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 1b0d4d5871cb..67b715af7869 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'--source-root-dir: expected absolute path, got "{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 a6752274efac..a7f12cde1f04 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 @@ class VisualStudio( 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 f07641041254..c366062cec7a 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 @@ class Tool(TestToolBase): """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 9935fe6a199d..c2a8bcef26cb 100644 --- a/cross-project-tests/lit.cfg.py +++ b/cross-project-tests/lit.cfg.py @@ -51,7 +51,7 @@ tools = [ 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 "