@@ -31,8 +31,7 @@ def __init__(self, verbose: bool, linter: PyLinter) -> None:
31
31
self .verbose_mode = verbose
32
32
self .linter = linter
33
33
34
- @staticmethod
35
- def _parse_ini_file (file_path : Path ) -> tuple [dict [str , str ], list [str ]]:
34
+ def _parse_ini_file (self , file_path : Path ) -> tuple [dict [str , str ], list [str ]]:
36
35
"""Parse and handle errors of a ini configuration file."""
37
36
parser = configparser .ConfigParser (inline_comment_prefixes = ("#" , ";" ))
38
37
@@ -43,7 +42,9 @@ def _parse_ini_file(file_path: Path) -> tuple[dict[str, str], list[str]]:
43
42
config_content : dict [str , str ] = {}
44
43
options : list [str ] = []
45
44
for section in parser .sections ():
46
- if "setup.cfg" in str (file_path ) and not section .startswith ("pylint" ):
45
+ if self ._ini_file_with_sections (str (file_path )) and not section .startswith (
46
+ "pylint"
47
+ ):
47
48
if section .lower () == "master" :
48
49
# TODO: 3.0: Remove deprecated handling of master, only allow 'pylint.' sections
49
50
warnings .warn (
@@ -60,6 +61,15 @@ def _parse_ini_file(file_path: Path) -> tuple[dict[str, str], list[str]]:
60
61
options += [f"--{ opt } " , value ]
61
62
return config_content , options
62
63
64
+ @staticmethod
65
+ def _ini_file_with_sections (file_path : str ) -> bool :
66
+ """Return whether the file uses sections."""
67
+ if "setup.cfg" in file_path :
68
+ return True
69
+ if "tox.ini" in file_path :
70
+ return True
71
+ return False
72
+
63
73
def _parse_toml_file (self , file_path : Path ) -> tuple [dict [str , str ], list [str ]]:
64
74
"""Parse and handle errors of a toml configuration file."""
65
75
try :
0 commit comments