-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable usage of custom pylintrc file for message documentation tests #6131
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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.") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Following an indented ``if`` block directly with an ``elif`` of lower indentation can lead to confusion whether the unindent is deliberate or accidental. | ||
Adding an explicit ``else`` in the indented ``if`` statement, even if it only contains a ``pass`` statement, can help clarify the code. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
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.") | ||
DanielNoord marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[MASTER] | ||
load-plugins=pylint.extensions.confusing_elif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
from collections import Counter | ||
from pathlib import Path | ||
from typing import Counter as CounterType | ||
from typing import List, TextIO, Tuple | ||
from typing import List, Optional, TextIO, Tuple | ||
|
||
import pytest | ||
|
||
|
@@ -53,7 +53,13 @@ def __init__(self, test_file: Tuple[str, Path]) -> None: | |
self._linter.config.persistent = 0 | ||
checkers.initialize(self._linter) | ||
|
||
config_file = next(config.find_default_config_files(), None) | ||
# Check if this message has a custom configuration file (e.g. for enabling optional checkers). | ||
# If not, use the default configuration. | ||
config_file: Optional[Path] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DanielNoord I think we talked about this already before but what do you think about using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was actually my initial approach, but the problem is that Besides the different folder structure, the tight coupling between the "original" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I advise against trying to use It's similar to your
DanielNoord marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (test_file[1].parent / "pylintrc").exists(): | ||
config_file = test_file[1].parent / "pylintrc" | ||
else: | ||
config_file = next(config.find_default_config_files(), None) | ||
|
||
_config_initialization( | ||
self._linter, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.