Method: pylint.config.arguments_manager._ArgumentsManager.read_config_file
Calls: 1, Exceptions: 0, Paths: 1Back
Path 1: 1 calls (1.0)
None (1)
False (1)
None (1)
1def read_config_file(
2 self, config_file: Path | None = None, verbose: bool = False
3 ) -> None: # pragma: no cover
4 """DEPRECATED: Read the configuration file but do not load it (i.e. dispatching
5 values to each option's provider).
6
7 :raises OSError: When the specified config file doesn't exist
8 """
9 warnings.warn(
10 "read_config_file has been deprecated. It will be removed in pylint 3.0.",
11 DeprecationWarning,
12 stacklevel=2,
13 )
14 if not config_file:
15 if verbose:
16 print(
17 "No config file found, using default configuration", file=sys.stderr
18 )
19 return
20 config_file = Path(os.path.expandvars(config_file)).expanduser()
21 if not config_file.exists():
22 raise OSError(f"The config file {str(config_file)} doesn't exist!")
23 parser = self.cfgfile_parser
24 if config_file.suffix == ".toml":
25 try:
26 self._parse_toml(config_file, parser)
27 except tomllib.TOMLDecodeError:
28 pass
29 else:
30 # Use this encoding in order to strip the BOM marker, if any.
31 with open(config_file, encoding="utf_8_sig") as fp:
32 parser.read_file(fp)
33 # normalize each section's title
34 for sect, values in list(parser._sections.items()): # type: ignore[attr-defined]
35 if sect.startswith("pylint."):
36 sect = sect[len("pylint.") :]
37 if not sect.isupper() and values:
38 parser._sections[sect.upper()] = values # type: ignore[attr-defined]
39
40 if verbose:
41 print(f"Using config file '{config_file}'", file=sys.stderr)