[clang-tools-extra] fix(clang-tools-extra/**.py): fix comparison to None (PR #94013)

Eisuke Kawashima via cfe-commits cfe-commits at lists.llvm.org
Fri May 31 12:25:28 PDT 2024


https://github.com/e-kwsm created https://github.com/llvm/llvm-project/pull/94013

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.

>From 0f57e398e77f3870f0367fffac0e440c2f4f1cbb 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(clang-tools-extra/**.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.
---
 .../clang-tidy/readability/IdentifierNamingCheck.cpp            | 2 +-
 .../docs/clang-tidy/checks/gen-static-analyzer-docs.py          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 828f13805a698..1b1857124eb0f 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -1071,7 +1071,7 @@ bool IdentifierNamingCheck::isParamInMainLikeFunction(
   if (!IsIntType(FDecl->parameters()[0]->getType()))
     return false;
   MainType Type = IsCharPtrPtr(FDecl->parameters()[1]->getType());
-  if (Type == None)
+  if (Type is None)
     return false;
   if (FDecl->getNumParams() == 3 &&
       IsCharPtrPtr(FDecl->parameters()[2]->getType()) != Type)
diff --git a/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py b/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
index 6545a3906fa50..53ecb60dec539 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
+++ b/clang-tools-extra/docs/clang-tidy/checks/gen-static-analyzer-docs.py
@@ -47,7 +47,7 @@ def get_checkers(checkers_td, checkers_rst):
         parent_package_ = package["ParentPackage"]
         hidden = (checker["Hidden"] != 0) or (package["Hidden"] != 0)
 
-        while parent_package_ != None:
+        while parent_package_ is not None:
             parent_package = table_entries[parent_package_["def"]]
             checker_package_prefix = (
                 parent_package["PackageName"] + "." + checker_package_prefix



More information about the cfe-commits mailing list