From 65800231072f05751b6c51b8c47b5a950bfbe691 Mon Sep 17 00:00:00 2001 From: Daniel D'Avella Date: Thu, 1 Feb 2024 16:03:20 -0500 Subject: [PATCH] Update metadata for literal-or-new-object-identity --- .../docs/pixee_python_literal-or-new-object-identity.md | 2 +- src/core_codemods/literal_or_new_object_identity.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core_codemods/docs/pixee_python_literal-or-new-object-identity.md b/src/core_codemods/docs/pixee_python_literal-or-new-object-identity.md index f634c3c47..88a5154a9 100644 --- a/src/core_codemods/docs/pixee_python_literal-or-new-object-identity.md +++ b/src/core_codemods/docs/pixee_python_literal-or-new-object-identity.md @@ -1,4 +1,4 @@ -The `is` and `is not` operator will only return `True` when the expression have the same `id`. In other words, `a is b` is equivalent to `id(a) == id(b)`. New objects and literals have their own identities and thus shouldn't be compared with using the `is` or `is not` operators. +The `is` and `is not` operators only evaluate to `True` when the expressions on each side have the same `id`. In other words, `a is b` is equivalent to `id(a) == id(b)`. With few exceptions, objects and literals have unique identities and thus shouldn't generally be compared by using the `is` or `is not` operators. Our changes look something like this: diff --git a/src/core_codemods/literal_or_new_object_identity.py b/src/core_codemods/literal_or_new_object_identity.py index 3e91b85f5..f71f9c969 100644 --- a/src/core_codemods/literal_or_new_object_identity.py +++ b/src/core_codemods/literal_or_new_object_identity.py @@ -12,7 +12,7 @@ class LiteralOrNewObjectIdentity(SimpleCodemod, NameAndAncestorResolutionMixin): metadata = Metadata( name="literal-or-new-object-identity", - summary="Replaces is operator with == for literal or new object comparisons", + summary="Replace `is` with `==` for literal or new object comparisons", review_guidance=ReviewGuidance.MERGE_WITHOUT_REVIEW, references=[ Reference( @@ -20,7 +20,7 @@ class LiteralOrNewObjectIdentity(SimpleCodemod, NameAndAncestorResolutionMixin): ), ], ) - change_description = "Replaces is operator with ==" + change_description = "Replaces `is` operator with `==`" def _is_object_creation_or_literal(self, node: cst.BaseExpression): match node: