From c8123d0ac847d79f3f8fcb53b8c5f3578a0bbd9d Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 2 May 2023 21:20:28 +0200 Subject: Uniformize message and remove useless details.rst --- doc/user_guide/checkers/features.rst | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'doc/user_guide/checkers/features.rst') 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 -- cgit v1.2.1