Method: pylint.config.config_file_parser._ConfigurationFileParser._parse_toml_file
Calls: 17, Exceptions: 2, Paths: 4Back
Path 1: 11 calls (0.65)
PosixPath (11)
tuple (11)
1def _parse_toml_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]:
2 """Parse and handle errors of a toml configuration file."""
3 try:
4 with open(file_path, mode="rb") as fp:
5 content = tomllib.load(fp)
6 except tomllib.TOMLDecodeError as e:
7 self.linter.add_message("config-parse-error", line=0, args=str(e))
8 return {}, []
9
10 try:
11 sections_values = content["tool"]["pylint"]
12 except KeyError:
13 return {}, []
14
15 config_content: dict[str, str] = {}
16 options: list[str] = []
17 for opt, values in sections_values.items():
18 if isinstance(values, dict):
19 for config, value in values.items():
20 value = _parse_rich_type_value(value)
21 config_content[config] = value
22 options += [f"--{config}", value]
23 else:
24 values = _parse_rich_type_value(values)
25 config_content[opt] = values
26 options += [f"--{opt}", values]
27 return config_content, options
Path 2: 4 calls (0.24)
PosixPath (4)
tuple (4)
1def _parse_toml_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]:
2 """Parse and handle errors of a toml configuration file."""
3 try:
4 with open(file_path, mode="rb") as fp:
5 content = tomllib.load(fp)
6 except tomllib.TOMLDecodeError as e:
7 self.linter.add_message("config-parse-error", line=0, args=str(e))
8 return {}, []
9
10 try:
11 sections_values = content["tool"]["pylint"]
12 except KeyError:
13 return {}, []
14
15 config_content: dict[str, str] = {}
16 options: list[str] = []
17 for opt, values in sections_values.items():
18 if isinstance(values, dict):
19 for config, value in values.items():
20 value = _parse_rich_type_value(value)
21 config_content[config] = value
22 options += [f"--{config}", value]
23 else:
24 values = _parse_rich_type_value(values)
25 config_content[opt] = values
26 options += [f"--{opt}", values]
27 return config_content, options
Path 3: 1 calls (0.06)
PosixPath (1)
tuple (1)
KeyError (1)
1def _parse_toml_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]:
2 """Parse and handle errors of a toml configuration file."""
3 try:
4 with open(file_path, mode="rb") as fp:
5 content = tomllib.load(fp)
6 except tomllib.TOMLDecodeError as e:
7 self.linter.add_message("config-parse-error", line=0, args=str(e))
8 return {}, []
9
10 try:
11 sections_values = content["tool"]["pylint"]
12 except KeyError:
13 return {}, []
14
15 config_content: dict[str, str] = {}
16 options: list[str] = []
17 for opt, values in sections_values.items():
18 if isinstance(values, dict):
19 for config, value in values.items():
20 value = _parse_rich_type_value(value)
21 config_content[config] = value
22 options += [f"--{config}", value]
23 else:
24 values = _parse_rich_type_value(values)
25 config_content[opt] = values
26 options += [f"--{opt}", values]
27 return config_content, options
Path 4: 1 calls (0.06)
PosixPath (1)
tuple (1)
TOMLDecodeError (1)
1def _parse_toml_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]:
2 """Parse and handle errors of a toml configuration file."""
3 try:
4 with open(file_path, mode="rb") as fp:
5 content = tomllib.load(fp)
6 except tomllib.TOMLDecodeError as e:
7 self.linter.add_message("config-parse-error", line=0, args=str(e))
8 return {}, []
9
10 try:
11 sections_values = content["tool"]["pylint"]
12 except KeyError:
13 return {}, []
14
15 config_content: dict[str, str] = {}
16 options: list[str] = []
17 for opt, values in sections_values.items():
18 if isinstance(values, dict):
19 for config, value in values.items():
20 value = _parse_rich_type_value(value)
21 config_content[config] = value
22 options += [f"--{config}", value]
23 else:
24 values = _parse_rich_type_value(values)
25 config_content[opt] = values
26 options += [f"--{opt}", values]
27 return config_content, options