summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2023-05-02 21:20:28 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2023-05-03 22:01:26 +0200
commitc8123d0ac847d79f3f8fcb53b8c5f3578a0bbd9d (patch)
tree10a2571524aad1533040c37d5425883eaebd1619 /doc
parentca74a1dbdabc138559d267e3adfef3893a1e795a (diff)
downloadpylint-git-c8123d0ac847d79f3f8fcb53b8c5f3578a0bbd9d.tar.gz
Uniformize message and remove useless details.rst
Diffstat (limited to 'doc')
-rw-r--r--doc/data/messages/u/use-implicit-booleaness-not-comparison-to-string/details.rst3
-rw-r--r--doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/details.rst3
-rw-r--r--doc/data/messages/u/use-implicit-booleaness-not-comparison/details.rst3
-rw-r--r--doc/user_guide/checkers/features.rst24
-rw-r--r--doc/whatsnew/fragments/6871.user_action4
5 files changed, 18 insertions, 19 deletions
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
deleted file mode 100644
index c5781b739..000000000
--- a/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-string/details.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-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``, 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
deleted file mode 100644
index 2f86acf54..000000000
--- a/doc/data/messages/u/use-implicit-booleaness-not-comparison-to-zero/details.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-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``, 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
deleted file mode 100644
index 0dc180245..000000000
--- a/doc/data/messages/u/use-implicit-booleaness-not-comparison/details.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-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/user_guide/checkers/features.rst b/doc/user_guide/checkers/features.rst
index ec6d11c2d..eb716d389 100644
--- a/doc/user_guide/checkers/features.rst
+++ b/doc/user_guide/checkers/features.rst
@@ -894,13 +894,20 @@ Refactoring checker Messages
of function or method definition. This statement can safely be removed
because Python will implicitly return None
:use-implicit-booleaness-not-comparison-to-string (C1804): *"%s" can be simplified to "%s", if it is striclty a string, as an empty string is falsey*
- Used when Pylint detects comparison to an empty string constant.
+ Empty string are considered false in a boolean context. 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``, an empty sequence, or ``0``) the code will not be equivalent.
:use-implicit-booleaness-not-comparison (C1803): *"%s" can be simplified to "%s", if it is strictly a sequence, as an empty %s is falsey*
- Used when Pylint detects that collection literal comparison is being used to
- check for emptiness; Use implicit booleaness instead of a collection classes;
- empty collections are considered as false
+ Empty sequences are considered false in a boolean context. 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.
:use-implicit-booleaness-not-comparison-to-zero (C1805): *"%s" can be simplified to "%s", if it is strictly an int, as 0 is falsey*
- Used when Pylint detects comparison to a 0 constant.
+ 0 is considered false in a boolean context. 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``, an empty
+ string, or an empty sequence) the code will not be equivalent.
:unneeded-not (C0113): *Consider changing "%s" to "%s"*
Used when a boolean expression contains an unneeded negation.
:consider-iterating-dictionary (C0201): *Consider iterating the dictionary directly instead of calling .keys()*
@@ -916,10 +923,9 @@ Refactoring checker Messages
Emitted when code that iterates with range and len is encountered. Such code
can be simplified by using the enumerate builtin.
:use-implicit-booleaness-not-len (C1802): *Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty*
- Used when Pylint detects that len(sequence) is being used without explicit
- comparison inside a condition to determine if a sequence is empty. Instead of
- coercing the length to a boolean, either rely on the fact that empty
- sequences are false or compare the length against a scalar.
+ Empty sequences are considered false in a boolean context. You can either
+ remove the call to 'len' (``if not x``) or compare the length against ascalar
+ (``if len(x) > 1``).
:consider-using-f-string (C0209): *Formatting a regular string which could be an f-string*
Used when we detect a string that is being formatted with format() or % which
could potentially be an f-string. The use of f-strings is preferred. Requires
diff --git a/doc/whatsnew/fragments/6871.user_action b/doc/whatsnew/fragments/6871.user_action
index eace82f7a..7cabc1ca1 100644
--- a/doc/whatsnew/fragments/6871.user_action
+++ b/doc/whatsnew/fragments/6871.user_action
@@ -9,7 +9,9 @@ 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.
+Messages related to implicit booleaness were made more explicit and actionable.
+
This permits to make their likeness explicit and will provide better performance as they share most of their
conditions to be raised.
-Refs #6871
+Closes #6871