From 74ff4c59eb58453cb4e276610f63baa70ee402e1 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 26 Apr 2023 23:12:18 +0200 Subject: [doc] Add warning for empty sequences in 'use-implicit-booleaness-not-comparison' --- .../details.rst | 4 ++-- .../details.rst | 4 ++-- .../details.rst | 3 +++ doc/whatsnew/fragments/6871.user_action | 19 ++++++++++--------- 4 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 doc/data/messages/u/use-implicit-booleaness-not-comparison/details.rst diff --git a/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-string/details.rst b/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-string/details.rst index 257fb92bc..c5781b739 100644 --- a/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-string/details.rst +++ b/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-string/details.rst @@ -1,3 +1,3 @@ Following this check blindly in weakly typed code base can create hard to debug issues. If the value -can be something else that is falsey but not a string (for example ``None``, or ``0``), the code will -not be equivalent. +can be something else that is falsey but not a string (for example ``None``, an empty sequence, or ``0``), +the code will not be equivalent. diff --git a/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/details.rst b/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/details.rst index 670633b2a..2f86acf54 100644 --- a/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/details.rst +++ b/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/details.rst @@ -1,3 +1,3 @@ Following this check blindly in weakly typed code base can create hard to debug issues. If the value -can be something else that is falsey but not an ``int`` (for example ``None``, or an empty string), -the code will not be equivalent. +can be something else that is falsey but not an ``int`` (for example ``None``, an empty sequence, +or an empty string), the code will not be equivalent. diff --git a/doc/data/messages/u/use-implicit-booleaness-not-comparison/details.rst b/doc/data/messages/u/use-implicit-booleaness-not-comparison/details.rst new file mode 100644 index 000000000..0dc180245 --- /dev/null +++ b/doc/data/messages/u/use-implicit-booleaness-not-comparison/details.rst @@ -0,0 +1,3 @@ +Following this check blindly in weakly typed code base can create hard to debug issues. If the value +can be something else that is falsey but not a sequence (for example ``None``, an empty string, or ``0``), +the code will not be equivalent. diff --git a/doc/whatsnew/fragments/6871.user_action b/doc/whatsnew/fragments/6871.user_action index e20983171..eace82f7a 100644 --- a/doc/whatsnew/fragments/6871.user_action +++ b/doc/whatsnew/fragments/6871.user_action @@ -1,12 +1,13 @@ -* The compare to empty string checker (``pylint.extensions.emptystring``) and the compare to - zero checker (``pylint.extensions.compare-to-zero``) have been removed and their checks are - now part of the implicit booleaness checker: - - - ``compare-to-zero`` was renamed ``use-implicit-booleaness-not-comparison-to-zero`` - and ``compare-to-empty-string`` was renamed ``use-implicit-booleaness-not-comparison-to-string`` - and they now need to be enabled explicitly. - - The `pylint.extensions.emptystring`` and ``pylint.extensions.compare-to-zero`` extensions no longer exists and - needs to be removed from the ``load-plugins`` option. +The compare to empty string checker (``pylint.extensions.emptystring``) and the compare to +zero checker (``pylint.extensions.compare-to-zero``) have been removed and their checks are +now part of the implicit booleaness checker: + +``compare-to-zero`` was renamed ``use-implicit-booleaness-not-comparison-to-zero`` and +``compare-to-empty-string`` was renamed ``use-implicit-booleaness-not-comparison-to-string`` +and they now need to be enabled explicitly. + +The `pylint.extensions.emptystring`` and ``pylint.extensions.compare-to-zero`` extensions +no longer exists and needs to be removed from the ``load-plugins`` option. This permits to make their likeness explicit and will provide better performance as they share most of their conditions to be raised. -- cgit v1.2.1