-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix parsing of unrelated options in tox.ini #6801
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
Changes from all 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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -31,8 +31,7 @@ def __init__(self, verbose: bool, linter: PyLinter) -> None: | |||||||||||||
self.verbose_mode = verbose | ||||||||||||||
self.linter = linter | ||||||||||||||
|
||||||||||||||
@staticmethod | ||||||||||||||
def _parse_ini_file(file_path: Path) -> tuple[dict[str, str], list[str]]: | ||||||||||||||
def _parse_ini_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]: | ||||||||||||||
"""Parse and handle errors of a ini configuration file.""" | ||||||||||||||
parser = configparser.ConfigParser(inline_comment_prefixes=("#", ";")) | ||||||||||||||
|
||||||||||||||
|
@@ -43,7 +42,9 @@ def _parse_ini_file(file_path: Path) -> tuple[dict[str, str], list[str]]: | |||||||||||||
config_content: dict[str, str] = {} | ||||||||||||||
options: list[str] = [] | ||||||||||||||
for section in parser.sections(): | ||||||||||||||
if "setup.cfg" in str(file_path) and not section.startswith("pylint"): | ||||||||||||||
if self._ini_file_with_sections(str(file_path)) and not section.startswith( | ||||||||||||||
"pylint" | ||||||||||||||
): | ||||||||||||||
if section.lower() == "master": | ||||||||||||||
# TODO: 3.0: Remove deprecated handling of master, only allow 'pylint.' sections | ||||||||||||||
warnings.warn( | ||||||||||||||
|
@@ -60,6 +61,15 @@ def _parse_ini_file(file_path: Path) -> tuple[dict[str, str], list[str]]: | |||||||||||||
options += [f"--{opt}", value] | ||||||||||||||
return config_content, options | ||||||||||||||
|
||||||||||||||
@staticmethod | ||||||||||||||
def _ini_file_with_sections(file_path: str) -> bool: | ||||||||||||||
"""Return whether the file uses sections.""" | ||||||||||||||
if "setup.cfg" in file_path: | ||||||||||||||
return True | ||||||||||||||
if "tox.ini" in file_path: | ||||||||||||||
return True | ||||||||||||||
return False | ||||||||||||||
Comment on lines
+67
to
+71
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.
Suggested change
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. Let's leave this as is. I can imagine we want to expand this. For example, by checking if a section starts with |
||||||||||||||
|
||||||||||||||
def _parse_toml_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]: | ||||||||||||||
"""Parse and handle errors of a toml configuration file.""" | ||||||||||||||
try: | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
; Test for https://github.com/PyCQA/pylint/issues/6800 | ||
|
||
[tox] | ||
skipsdist = True | ||
envlist = py3, pylint | ||
|
||
[testenv] | ||
setenv = PYTHONWARNINGS=ignore | ||
|
||
[testenv:pylint] | ||
deps = | ||
pylint | ||
|
||
|
||
[pylint] | ||
jobs = 10 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"jobs": 10 | ||
} |
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.
Tremor of the removal of
no-self-use
😄 ?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.
Yes!