-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable usage of custom pylintrc file for message documentation tests (#…
…6131) Demonstrate it with optional checker message as example. Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
- Loading branch information
1 parent
be43fff
commit 236313a
Showing
5 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def myfunc(shall_continue: bool, shall_exit: bool): | ||
if shall_continue: | ||
if input("Are you sure?") == "y": | ||
print("Moving on.") | ||
elif shall_exit: # [confusing-consecutive-elif] | ||
print("Exiting.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Creating a function for the nested conditional, or adding an explicit ``else`` in the indented ``if`` statement, even if it only contains a ``pass`` statement, can help clarify the code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Option 1: add explicit 'else' | ||
def myfunc(shall_continue: bool, shall_exit: bool): | ||
if shall_continue: | ||
if input("Are you sure?") == "y": | ||
print("Moving on.") | ||
else: | ||
pass | ||
elif shall_exit: | ||
print("Exiting.") | ||
|
||
|
||
# Option 2: extract function | ||
def user_confirmation(): | ||
if input("Are you sure?") == "y": | ||
print("Moving on.") | ||
|
||
|
||
def myfunc2(shall_continue: bool, shall_exit: bool): | ||
if shall_continue: | ||
user_confirmation() | ||
elif shall_exit: | ||
print("Exiting.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[MASTER] | ||
load-plugins=pylint.extensions.confusing_elif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters