Method: pylint.config.config_initialization._config_initialization
Calls: 1078, Exceptions: 1077, Paths: 22Back
Path 1: 738 calls (0.68)
PyLinter (738)
[''] (3) ['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/regrtest_data/unused_variable.py', '--persistent=no'] (2) ['/Users/andreho...
FunctionalTestReporter (727) TextReporter (5) JSONReporter (3) GenericTestReporter (2) MultiReporter (1)
PosixPath (522) '/Users/andrehora/Documents/git/projects-pathspotter/pylint/pylint/testutils/testing_pylintrc' (10) '/Users/andrehora/Documents/git/pr...
False (738)
[''] (3) ['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/functional/a/arguments.py'] (2) ['/Users/andrehora/Documents/git/projects-...
ValueError (738)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 2: 195 calls (0.18)
PyLinter (195)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/file_to_lint.py'] (53) ['/Users/andrehora/Documents/git/projects-pathspotter...
None (195)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/pylint/testutils/testing_pylintrc' (136) None (3) '/Users/andrehora/Documents/git/projects...
False (194) True (1)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/file_to_lint.py'] (53) ['/Users/andrehora/Documents/git/projects-pathspotter...
ValueError (195)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 3: 90 calls (0.08)
PyLinter (90)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/functional/ext/dict_init_mutate.py'] (1) ['/Users/andrehora/Documents/git/projects-...
FunctionalTestReporter (90)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/functional/ext/dict_init_mutate.rc' (1) '/Users/andrehora/Documents/git/projects-pat...
False (90)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/functional/ext/dict_init_mutate.py'] (1) ['/Users/andrehora/Documents/git/projects-...
ValueError (90)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 4: 17 calls (0.02)
PyLinter (17)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/file_to_lint.py'] (4) ['/var/folders/yp/qx0crmvd4sbck7chb52sws500000gn/T/tmp...
None (17)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/pylintrc' (11) '/var/folders/yp/qx0crmvd4sbck7chb52sws500000gn/T/tmpah3s6tes' (1) '/Users/...
False (17)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/file_to_lint.py'] (4) ['/Users/andrehora/Documents/git/projects-pathspotter/...
ValueError (17)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 5: 7 calls (0.01)
PyLinter (7)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/data/clientmodule_test.py', '--indent-string=', '--persistent=no'] (1) ['--generate...
None (7)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/pylint/testutils/testing_pylintrc' (6) '' (1)
False (7)
SystemExit (7)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 6: 6 calls (0.01)
PyLinter (6)
[] (3) ['--persistent=no'] (1) ['--from-stdin', '--persistent=no'] (1) ['--errors-only'] (1)
None (6)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/pylint/testutils/testing_pylintrc' (4) None (2)
False (3) True (3)
[] (6)
ValueError (6)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 7: 4 calls (0.0)
PyLinter (4)
['--help-msg', 'dummy-message-01', 'dummy-message-02', '--persistent=no'] (1) ['--generate-rcfile', '--persistent=no'] (1) ['generate', '-h'] (1) ['']...
None (4)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/regrtest_data/dummy_plugin.rc' (2) '/Users/andrehora/Documents/git/projects-pathspot...
False (4)
SystemExit (4)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 8: 4 calls (0.0)
PyLinter (4)
['-h'] (2) [] (1) ['generate'] (1)
None (4)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/pylintrc' (4)
False (4)
[] (4)
ValueError (4)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 9: 3 calls (0.0)
PyLinter (3)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/lint/../regrtest_data/empty.py'] (2) ['/Users/andrehora/Documents/git/projects-path...
None (3)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/functional/setup_cfg/issue_3630/not_setup.cfg' (1) '/var/folders/yp/qx0crmvd4...
False (3)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/lint/../regrtest_data/empty.py'] (2) ['/Users/andrehora/Documents/git/projects-path...
ValueError (3)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 10: 2 calls (0.0)
PyLinter (2)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/file_to_lint.py'] (2)
None (2)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/functional/ini/pylintrc_with_quoted_init_hook.ini' (1) '/Users/andrehora/Docu...
False (2)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/file_to_lint.py'] (2)
ValueError (2)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 11: 1 calls (0.0)
PyLinter (1)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/functional/e/empty_docstring.py'] (1)
FunctionalTestReporter (1)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/functional/e/empty_docstring.rc' (1)
False (1)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/functional/e/empty_docstring.py'] (1)
ValueError (1)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 12: 1 calls (0.0)
PyLinter (1)
['--persistent=no'] (1)
None (1)
'/tmp/this_file_does_not_exist' (1)
False (1)
SystemExit (1)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 13: 1 calls (0.0)
PyLinter (1)
['--ignore-patterns=a', '--persistent=no'] (1)
TextReporter (1)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/pylint/testutils/testing_pylintrc' (1)
False (1)
[] (1)
ValueError (1)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 14: 1 calls (0.0)
PyLinter (1)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/../regrtest_data/empty.py', '--unknown-option=yes'] (1)
None (1)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/pylint/testutils/testing_pylintrc' (1)
False (1)
SystemExit (1)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 15: 1 calls (0.0)
PyLinter (1)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/../regrtest_data/empty.py', '-Q'] (1)
None (1)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/pylint/testutils/testing_pylintrc' (1)
False (1)
SystemExit (1)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 16: 1 calls (0.0)
PyLinter (1)
['--', '/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/../regrtest_data/empty.py'] (1)
None (1)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/pylint/testutils/testing_pylintrc' (1)
False (1)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/../regrtest_data/empty.py'] (1)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 17: 1 calls (0.0)
PyLinter (1)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/file_to_lint.py'] (1)
None (1)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/functional/toml/toml_with_unknown_option.toml' (1)
False (1)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/file_to_lint.py'] (1)
ValueError (1)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 18: 1 calls (0.0)
PyLinter (1)
['--never-use-this'] (1)
None (1)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/pylintrc' (1)
False (1)
SystemExit (1)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 19: 1 calls (0.0)
PyLinter (1)
[] (1)
None (1)
'/private/var/folders/yp/qx0crmvd4sbck7chb52sws500000gn/T/pytest-of-andrehora/pytest-178/test_run_pylint_with_invalid_a0/testpylintrc' (1)
False (1)
SystemExit (1)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 20: 1 calls (0.0)
PyLinter (1)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/lint/../regrtest_data/empty.py'] (1)
GenericTestReporter (1)
'/var/folders/yp/qx0crmvd4sbck7chb52sws500000gn/T/tmpv756lg87fake-home/pylintrc' (1)
False (1)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/lint/../regrtest_data/empty.py'] (1)
ValueError (1)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 21: 1 calls (0.0)
PyLinter (1)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/lint/../regrtest_data/empty.py'] (1)
GenericTestReporter (1)
'/var/folders/yp/qx0crmvd4sbck7chb52sws500000gn/T/tmpbdut9cb0fake-home/pylintrc' (1)
False (1)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/lint/../regrtest_data/empty.py'] (1)
ValueError (1)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list
Path 22: 1 calls (0.0)
PyLinter (1)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/testutils/data/init_hook.py'] (1)
FunctionalTestReporter (1)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/testutils/data/init_hook.rc' (1)
False (1)
RuntimeError (1)
1def _config_initialization(
2 linter: PyLinter,
3 args_list: list[str],
4 reporter: reporters.BaseReporter | reporters.MultiReporter | None = None,
5 config_file: None | str | Path = None,
6 verbose_mode: bool = False,
7) -> list[str]:
8 """Parse all available options, read config files and command line arguments and
9 set options accordingly.
10 """
11 config_file = Path(config_file) if config_file else None
12
13 # Set the current module to the configuration file
14 # to allow raising messages on the configuration file.
15 linter.set_current_module(str(config_file) if config_file else "")
16
17 # Read the configuration file
18 config_file_parser = _ConfigurationFileParser(verbose_mode, linter)
19 try:
20 config_data, config_args = config_file_parser.parse_config_file(
21 file_path=config_file
22 )
23 except OSError as ex:
24 print(ex, file=sys.stderr)
25 sys.exit(32)
26
27 # Run init hook, if present, before loading plugins
28 if "init-hook" in config_data:
29 exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
30
31 # Load plugins if specified in the config file
32 if "load-plugins" in config_data:
33 linter.load_plugin_modules(utils._splitstrip(config_data["load-plugins"]))
34
35 unrecognized_options_message = None
36 # First we parse any options from a configuration file
37 try:
38 linter._parse_configuration_file(config_args)
39 except _UnrecognizedOptionError as exc:
40 unrecognized_options_message = ", ".join(exc.options)
41
42 # Then, if a custom reporter is provided as argument, it may be overridden
43 # by file parameters, so we re-set it here. We do this before command line
44 # parsing, so it's still overridable by command line options
45 if reporter:
46 linter.set_reporter(reporter)
47
48 # Set the current module to the command line
49 # to allow raising messages on it
50 linter.set_current_module("Command line")
51
52 # Now we parse any options from the command line, so they can override
53 # the configuration file
54 parsed_args_list = linter._parse_command_line_configuration(args_list)
55
56 # Remove the positional arguments separator from the list of arguments if it exists
57 try:
58 parsed_args_list.remove("--")
59 except ValueError:
60 pass
61
62 # Check if there are any options that we do not recognize
63 unrecognized_options: list[str] = []
64 for opt in parsed_args_list:
65 if opt.startswith("--"):
66 unrecognized_options.append(opt[2:])
67 elif opt.startswith("-"):
68 unrecognized_options.append(opt[1:])
69 if unrecognized_options:
70 msg = ", ".join(unrecognized_options)
71 try:
72 linter._arg_parser.error(f"Unrecognized option found: {msg}")
73 except SystemExit:
74 sys.exit(32)
75
76 # Now that config file and command line options have been loaded
77 # with all disables, it is safe to emit messages
78 if unrecognized_options_message is not None:
79 linter.set_current_module(str(config_file) if config_file else "")
80 linter.add_message(
81 "unrecognized-option", args=unrecognized_options_message, line=0
82 )
83
84 linter._emit_stashed_messages()
85
86 # Set the current module to configuration as we don't know where
87 # the --load-plugins key is coming from
88 linter.set_current_module("Command line or configuration file")
89
90 # We have loaded configuration from config file and command line. Now, we can
91 # load plugin specific configuration.
92 linter.load_plugin_configuration()
93
94 # Now that plugins are loaded, get list of all fail_on messages, and enable them
95 linter.enable_fail_on_messages()
96
97 linter._parse_error_mode()
98
99 # Link the base Namespace object on the current directory
100 linter._directory_namespaces[Path(".").resolve()] = (linter.config, {})
101
102 # parsed_args_list should now only be a list of files/directories to lint.
103 # All other options have been removed from the list.
104 return parsed_args_list