|
5 | 5 | """Arguments manager class used to handle command-line arguments and options.""" |
6 | 6 |
|
7 | 7 | import argparse |
8 | | -from typing import TYPE_CHECKING, Dict, List |
| 8 | +import sys |
| 9 | +from typing import TYPE_CHECKING, Dict, List, Optional |
9 | 10 |
|
10 | 11 | from pylint.config.argument import ( |
11 | 12 | _Argument, |
@@ -33,7 +34,6 @@ def __init__(self) -> None: |
33 | 34 | self._arg_parser = argparse.ArgumentParser( |
34 | 35 | prog="pylint", |
35 | 36 | usage="%(prog)s [options]", |
36 | | - allow_abbrev=False, |
37 | 37 | formatter_class=_HelpFormatter, |
38 | 38 | ) |
39 | 39 | """The command line argument parser.""" |
@@ -145,15 +145,17 @@ def _parse_configuration_file(self, config_data: Dict[str, str]) -> None: |
145 | 145 | # TODO: This should parse_args instead of parse_known_args |
146 | 146 | self.namespace = self._arg_parser.parse_known_args(arguments, self.namespace)[0] |
147 | 147 |
|
148 | | - def _parse_command_line_configuration(self, arguments: List[str]) -> None: |
| 148 | + def _parse_command_line_configuration( |
| 149 | + self, arguments: Optional[List[str]] = None |
| 150 | + ) -> List[str]: |
149 | 151 | """Parse the arguments found on the command line into the namespace.""" |
150 | | - # pylint: disable-next=fixme |
151 | | - # TODO: This should parse_args instead of parse_known_args |
152 | | - self.namespace = self._arg_parser.parse_known_args(arguments, self.namespace)[0] |
| 152 | + arguments = sys.argv[1:] if arguments is None else arguments |
153 | 153 |
|
154 | | - # pylint: disable-next=fixme |
155 | | - # TODO: This should return a list of arguments with the option arguments removed |
156 | | - # just as PyLinter.load_command_line_configuration does |
| 154 | + self.namespace, parsed_args = self._arg_parser.parse_known_args( |
| 155 | + arguments, self.namespace |
| 156 | + ) |
| 157 | + |
| 158 | + return parsed_args |
157 | 159 |
|
158 | 160 | def _parse_plugin_configuration(self) -> None: |
159 | 161 | # pylint: disable-next=fixme |
|
0 commit comments