[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.
This commit is contained in:
Eisuke Kawashima
2025-01-13 21:03:04 +09:00
committed by GitHub
parent b605dab7a8
commit ca92bdfa3e
7 changed files with 8 additions and 8 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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)

View File

@@ -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}"</>'

View File

@@ -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
)

View File

@@ -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),

View File

@@ -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 "