Skip to content

Commit 838d8ff

Browse files
Merge the empty-string extensions to 'implicit_booleaness_checker'
1 parent 1b146f4 commit 838d8ff

File tree

19 files changed

+109
-144
lines changed

19 files changed

+109
-144
lines changed

doc/data/messages/c/compare-to-empty-string/bad.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

doc/data/messages/c/compare-to-empty-string/good.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

doc/data/messages/c/compare-to-empty-string/pylintrc

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def important_string_manipulation(x: str, y: str) -> None:
2+
if x == "": # [use-implicit-booleaness-not-comparison-to-string]
3+
print("x is an empty string")
4+
5+
if y != "": # [use-implicit-booleaness-not-comparison-to-string]
6+
print("y is not an empty string")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Following this check blindly in weakly typed code base can create hard to debug issues. If the value
2+
can be something else than an int (for example ``None``), the code will not be equivalent as None
3+
is not an empty string but it's falsey too.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def important_string_manipulation(x: str, y: str) -> None:
2+
if not x:
3+
print("x is an empty string")
4+
5+
if y:
6+
print("y is not an empty string")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[main]
2+
enable=use-implicit-booleaness-not-comparison-to-string

doc/user_guide/checkers/extensions.rst

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Pylint provides the following optional plugins:
1919
- :ref:`pylint.extensions.docstyle`
2020
- :ref:`pylint.extensions.dunder`
2121
- :ref:`pylint.extensions.empty_comment`
22-
- :ref:`pylint.extensions.emptystring`
2322
- :ref:`pylint.extensions.eq_without_hash`
2423
- :ref:`pylint.extensions.for_any_all`
2524
- :ref:`pylint.extensions.magic_value`
@@ -87,20 +86,6 @@ Code Style checker Messages
8786
to. This can be changed to be an augmented assign. Disabled by default!
8887

8988

90-
.. _pylint.extensions.emptystring:
91-
92-
Compare-To-Empty-String checker
93-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94-
95-
This checker is provided by ``pylint.extensions.emptystring``.
96-
Verbatim name of the checker is ``compare-to-empty-string``.
97-
98-
Compare-To-Empty-String checker Messages
99-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
100-
:compare-to-empty-string (C1901): *"%s" can be simplified to "%s" as an empty string is falsey*
101-
Used when Pylint detects comparison to an empty string constant.
102-
103-
10489
.. _pylint.extensions.comparison_placement:
10590

10691
Comparison-Placement checker

doc/user_guide/checkers/features.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,10 @@ Refactoring checker Messages
893893
Emitted when a single "return" or "return None" statement is found at the end
894894
of function or method definition. This statement can safely be removed
895895
because Python will implicitly return None
896-
:use-implicit-booleaness-not-comparison-to-zero (C1804): *"%s" can be simplified to "%s" as 0 is falsey*
896+
:use-implicit-booleaness-not-comparison-to-zero (C1805): *"%s" can be simplified to "%s" as 0 is falsey*
897897
Used when Pylint detects comparison to a 0 constant.
898+
:use-implicit-booleaness-not-comparison-to-string (C1804): *"%s" can be simplified to "%s" as an empty string is falsey*
899+
Used when Pylint detects comparison to an empty string constant.
898900
:use-implicit-booleaness-not-comparison (C1803): *'%s' can be simplified to '%s' as an empty %s is falsey*
899901
Used when Pylint detects that collection literal comparison is being used to
900902
check for emptiness; Use implicit booleaness instead of a collection classes;

doc/user_guide/configuration/all-options.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ Standard Checkers
233233
234234
confidence = ["HIGH", "CONTROL_FLOW", "INFERENCE", "INFERENCE_FAILURE", "UNDEFINED"]
235235
236-
disable = ["raw-checker-failed", "bad-inline-option", "locally-disabled", "file-ignored", "suppressed-message", "useless-suppression", "deprecated-pragma", "use-implicit-booleaness-not-comparison-to-zero", "use-symbolic-message-instead", "consider-using-augmented-assign"]
236+
disable = ["raw-checker-failed", "bad-inline-option", "locally-disabled", "file-ignored", "suppressed-message", "useless-suppression", "deprecated-pragma", "use-implicit-booleaness-not-comparison-to-string", "use-implicit-booleaness-not-comparison-to-zero", "use-symbolic-message-instead", "consider-using-augmented-assign"]
237237
238238
enable = []
239239

0 commit comments

Comments
 (0)