Method: pylint.config.config_file_parser._ConfigurationFileParser._parse_ini_file
Calls: 1053, Exceptions: 1, Paths: 6Back
Path 1: 1015 calls (0.96)
PosixPath (1015)
tuple (1015)
1def _parse_ini_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]:
2 """Parse and handle errors of a ini configuration file."""
3 parser = configparser.ConfigParser(inline_comment_prefixes=("#", ";"))
4
5 # Use this encoding in order to strip the BOM marker, if any.
6 with open(file_path, encoding="utf_8_sig") as fp:
7 parser.read_file(fp)
8
9 config_content: dict[str, str] = {}
10 options: list[str] = []
11 for section in parser.sections():
12 if self._ini_file_with_sections(file_path) and not section.startswith(
13 "pylint"
14 ):
15 if section.lower() == "master":
16 # TODO: 3.0: Remove deprecated handling of master, only allow 'pylint.' sections
17 warnings.warn(
18 "The use of 'MASTER' or 'master' as configuration section for pylint "
19 "has been deprecated, as it's bad practice to not start sections titles with the "
20 "tool name. Please use 'pylint.main' instead.",
21 UserWarning,
22 )
23 else:
24 continue
25 for opt, value in parser[section].items():
26 config_content[opt] = value
27 options += [f"--{opt}", value]
28 return config_content, options
Path 2: 30 calls (0.03)
PosixPath (30)
tuple (30)
1def _parse_ini_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]:
2 """Parse and handle errors of a ini configuration file."""
3 parser = configparser.ConfigParser(inline_comment_prefixes=("#", ";"))
4
5 # Use this encoding in order to strip the BOM marker, if any.
6 with open(file_path, encoding="utf_8_sig") as fp:
7 parser.read_file(fp)
8
9 config_content: dict[str, str] = {}
10 options: list[str] = []
11 for section in parser.sections():
12 if self._ini_file_with_sections(file_path) and not section.startswith(
13 "pylint"
14 ):
15 if section.lower() == "master":
16 # TODO: 3.0: Remove deprecated handling of master, only allow 'pylint.' sections
17 warnings.warn(
18 "The use of 'MASTER' or 'master' as configuration section for pylint "
19 "has been deprecated, as it's bad practice to not start sections titles with the "
20 "tool name. Please use 'pylint.main' instead.",
21 UserWarning,
22 )
23 else:
24 continue
25 for opt, value in parser[section].items():
26 config_content[opt] = value
27 options += [f"--{opt}", value]
28 return config_content, options
Path 3: 4 calls (0.0)
PosixPath (4)
tuple (4)
1def _parse_ini_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]:
2 """Parse and handle errors of a ini configuration file."""
3 parser = configparser.ConfigParser(inline_comment_prefixes=("#", ";"))
4
5 # Use this encoding in order to strip the BOM marker, if any.
6 with open(file_path, encoding="utf_8_sig") as fp:
7 parser.read_file(fp)
8
9 config_content: dict[str, str] = {}
10 options: list[str] = []
11 for section in parser.sections():
12 if self._ini_file_with_sections(file_path) and not section.startswith(
13 "pylint"
14 ):
15 if section.lower() == "master":
16 # TODO: 3.0: Remove deprecated handling of master, only allow 'pylint.' sections
17 warnings.warn(
18 "The use of 'MASTER' or 'master' as configuration section for pylint "
19 "has been deprecated, as it's bad practice to not start sections titles with the "
20 "tool name. Please use 'pylint.main' instead.",
21 UserWarning,
22 )
23 else:
24 continue
25 for opt, value in parser[section].items():
26 config_content[opt] = value
27 options += [f"--{opt}", value]
28 return config_content, options
Path 4: 2 calls (0.0)
PosixPath (2)
tuple (2)
1def _parse_ini_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]:
2 """Parse and handle errors of a ini configuration file."""
3 parser = configparser.ConfigParser(inline_comment_prefixes=("#", ";"))
4
5 # Use this encoding in order to strip the BOM marker, if any.
6 with open(file_path, encoding="utf_8_sig") as fp:
7 parser.read_file(fp)
8
9 config_content: dict[str, str] = {}
10 options: list[str] = []
11 for section in parser.sections():
12 if self._ini_file_with_sections(file_path) and not section.startswith(
13 "pylint"
14 ):
15 if section.lower() == "master":
16 # TODO: 3.0: Remove deprecated handling of master, only allow 'pylint.' sections
17 warnings.warn(
18 "The use of 'MASTER' or 'master' as configuration section for pylint "
19 "has been deprecated, as it's bad practice to not start sections titles with the "
20 "tool name. Please use 'pylint.main' instead.",
21 UserWarning,
22 )
23 else:
24 continue
25 for opt, value in parser[section].items():
26 config_content[opt] = value
27 options += [f"--{opt}", value]
28 return config_content, options
Path 5: 1 calls (0.0)
PosixPath (1)
InterpolationSyntaxError (1)
1def _parse_ini_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]:
2 """Parse and handle errors of a ini configuration file."""
3 parser = configparser.ConfigParser(inline_comment_prefixes=("#", ";"))
4
5 # Use this encoding in order to strip the BOM marker, if any.
6 with open(file_path, encoding="utf_8_sig") as fp:
7 parser.read_file(fp)
8
9 config_content: dict[str, str] = {}
10 options: list[str] = []
11 for section in parser.sections():
12 if self._ini_file_with_sections(file_path) and not section.startswith(
13 "pylint"
14 ):
15 if section.lower() == "master":
16 # TODO: 3.0: Remove deprecated handling of master, only allow 'pylint.' sections
17 warnings.warn(
18 "The use of 'MASTER' or 'master' as configuration section for pylint "
19 "has been deprecated, as it's bad practice to not start sections titles with the "
20 "tool name. Please use 'pylint.main' instead.",
21 UserWarning,
22 )
23 else:
24 continue
25 for opt, value in parser[section].items():
26 config_content[opt] = value
27 options += [f"--{opt}", value]
28 return config_content, options
Path 6: 1 calls (0.0)
PosixPath (1)
tuple (1)
1def _parse_ini_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]:
2 """Parse and handle errors of a ini configuration file."""
3 parser = configparser.ConfigParser(inline_comment_prefixes=("#", ";"))
4
5 # Use this encoding in order to strip the BOM marker, if any.
6 with open(file_path, encoding="utf_8_sig") as fp:
7 parser.read_file(fp)
8
9 config_content: dict[str, str] = {}
10 options: list[str] = []
11 for section in parser.sections():
12 if self._ini_file_with_sections(file_path) and not section.startswith(
13 "pylint"
14 ):
15 if section.lower() == "master":
16 # TODO: 3.0: Remove deprecated handling of master, only allow 'pylint.' sections
17 warnings.warn(
18 "The use of 'MASTER' or 'master' as configuration section for pylint "
19 "has been deprecated, as it's bad practice to not start sections titles with the "
20 "tool name. Please use 'pylint.main' instead.",
21 UserWarning,
22 )
23 else:
24 continue
25 for opt, value in parser[section].items():
26 config_content[opt] = value
27 options += [f"--{opt}", value]
28 return config_content, options