Skip to content

Commit

Permalink
[deprecation] setup.cfgand tox.ini sections need to start by …
Browse files Browse the repository at this point in the history
…'pylint' (#8465)
  • Loading branch information
Pierre-Sassoulas committed Mar 20, 2023
1 parent 699ac88 commit a479303
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
5 changes: 5 additions & 0 deletions doc/whatsnew/fragments/8464.user_action
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Following a deprecation period, it's no longer possible to use ``MASTER``
or ``master`` as configuration section in ``setup.cfg`` or ``tox.ini``. It's bad practice
to not start sections titles with the tool name. Please use ``pylint.main`` instead.

Refs #8464
23 changes: 6 additions & 17 deletions pylint/config/config_file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import configparser
import os
import sys
import warnings
from pathlib import Path
from typing import TYPE_CHECKING

Expand Down Expand Up @@ -41,23 +40,13 @@ def _parse_ini_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]:

config_content: dict[str, str] = {}
options: list[str] = []
ini_file_with_sections = self._ini_file_with_sections(file_path)
for section in parser.sections():
if self._ini_file_with_sections(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(
"The use of 'MASTER' or 'master' as configuration section for pylint "
"has been deprecated, as it's bad practice to not start sections titles "
"with the tool name. Please use 'pylint.main' instead.",
UserWarning,
)
else:
continue
for opt, value in parser[section].items():
config_content[opt] = value
options += [f"--{opt}", value]
if ini_file_with_sections and not section.startswith("pylint"):
continue
for option, value in parser[section].items():
config_content[option] = value
options += [f"--{option}", value]
return config_content, options

@staticmethod
Expand Down
3 changes: 0 additions & 3 deletions tests/config/functional/setup_cfg/deprecate_master/setup.cfg

This file was deleted.

This file was deleted.

0 comments on commit a479303

Please sign in to comment.