Skip to content

Commit 7e4bb03

Browse files
Code review
Co-authored-by: Pierre Sassoulas <[email protected]>
1 parent b08beb4 commit 7e4bb03

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
def func(expr, node_cls):
2-
# +1:[improve-conditionals]
3-
if not isinstance(expr, node_cls) or expr.attrname != "__init__":
4-
...
1+
def is_penguin(animal):
2+
# Penguins are the only flightless, kneeless sea birds
3+
return animal.is_seabird() and (
4+
not animal.can_fly() or not animal.has_visible_knee() # [improve-conditionals]
5+
)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
def func(expr, node_cls):
2-
if not (isinstance(expr, node_cls) and expr.attrname == "__init__"):
3-
...
1+
def is_penguin(animal):
2+
# Penguins are the only flightless, kneeless sea birds
3+
return animal.is_seabird() and not (animal.can_fly() or animal.has_visible_knee())

doc/user_guide/checkers/extensions.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ Code Style checker Messages
8989
readability (it's also faster as it avoids an internal exec call). Disabled
9090
by default!
9191
:improve-conditionals (R6106): *Rewrite conditional expression to '%s'*
92-
Rewrite negated if expressions to improve readability.
92+
Rewrite negated if expressions to improve readability. This style is simpler
93+
and also permits converting long if/elif chains to match case with more ease.
94+
Disabled by default!
9395

9496

9597
.. _pylint.extensions.comparison_placement:

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 = ["bad-inline-option", "consider-using-augmented-assign", "deprecated-pragma", "file-ignored", "locally-disabled", "prefer-typing-namedtuple", "raw-checker-failed", "suppressed-message", "use-implicit-booleaness-not-comparison-to-string", "use-implicit-booleaness-not-comparison-to-zero", "use-symbolic-message-instead", "useless-suppression"]
236+
disable = ["bad-inline-option", "consider-using-augmented-assign", "deprecated-pragma", "file-ignored", "improve-conditionals", "locally-disabled", "prefer-typing-namedtuple", "raw-checker-failed", "suppressed-message", "use-implicit-booleaness-not-comparison-to-string", "use-implicit-booleaness-not-comparison-to-zero", "use-symbolic-message-instead", "useless-suppression"]
237237
238238
enable = []
239239

pylint/extensions/code_style.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ class CodeStyleChecker(BaseChecker):
8585
"R6106": (
8686
"Rewrite conditional expression to '%s'",
8787
"improve-conditionals",
88-
"Rewrite negated if expressions to improve readability.",
88+
"Rewrite negated if expressions to improve readability. This style is simpler "
89+
"and also permits converting long if/elif chains to match case with more ease.\n"
90+
"Disabled by default!",
8991
{
90-
# "default_enabled": False,
92+
"default_enabled": False,
9193
},
9294
),
9395
}

pylint/extensions/private_import.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def _name_is_private(name: str) -> bool:
108108
return (
109109
bool(name)
110110
and name[0] == "_"
111-
and not (len(name) > 4 and name[:2] == "__" and name[-2:] == "__")
111+
and not (len(name) > 4 and name[1] == "_" and name[-2:] == "__")
112112
)
113113

114114
def _get_type_annotation_names(

0 commit comments

Comments
 (0)