diff options
| author | Anthony Sottile <asottile@umich.edu> | 2019-08-29 20:09:47 +0000 |
|---|---|---|
| committer | Anthony Sottile <asottile@umich.edu> | 2019-08-29 20:09:47 +0000 |
| commit | 45ad2faf8f8f3bbeb882f6f98c850ee5e09a897a (patch) | |
| tree | 442ed06e7fc4bf4e90449f73e74d878b93bf8542 /src | |
| parent | 8b34b334fa6cedded614d0ad47fef8d0544d701a (diff) | |
| parent | cf4bc53c127d7e6c29f69fcd0a1920d0aa88c023 (diff) | |
| download | flake8-45ad2faf8f8f3bbeb882f6f98c850ee5e09a897a.tar.gz | |
Merge branch 'hoist-argv' into 'master'
Hoist passing through sys.argv at the CLI layer
See merge request pycqa/flake8!345
Diffstat (limited to 'src')
| -rw-r--r-- | src/flake8/main/application.py | 18 | ||||
| -rw-r--r-- | src/flake8/main/cli.py | 4 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/flake8/main/application.py b/src/flake8/main/application.py index 6e5373f..6393dad 100644 --- a/src/flake8/main/application.py +++ b/src/flake8/main/application.py @@ -97,8 +97,8 @@ class Application(object): #: The parsed diff information self.parsed_diff = {} # type: Dict[str, Set[int]] - def parse_preliminary_options_and_args(self, argv=None): - # type: (Optional[List[str]]) -> None + def parse_preliminary_options_and_args(self, argv): + # type: (List[str]) -> None """Get preliminary options and args from CLI, pre-plugin-loading. We need to know the values of a few standard options and args now, so @@ -121,7 +121,7 @@ class Application(object): # do not need to worry and we can continue. If it is, we successfully # defer printing the version until just a little bit later. # Similarly we have to defer printing the help text until later. - args = (argv if argv is not None else sys.argv)[:] + args = argv[:] try: args.remove("--version") except ValueError: @@ -136,8 +136,8 @@ class Application(object): pass opts, args = self.option_manager.parse_known_args(args) - # parse_known_args includes program name and unknown options as args - args = [a for a in args[1:] if not a.startswith("-")] + # parse_known_args includes unknown options as args + args = [a for a in args if not a.startswith("-")] self.prelim_opts, self.prelim_args = opts, args def exit(self): @@ -344,7 +344,7 @@ class Application(object): self.formatter.show_statistics(self.guide.stats) def initialize(self, argv): - # type: (Optional[List[str]]) -> None + # type: (List[str]) -> None """Initialize the application to be run. This finds the plugins, registers their options, and parses the @@ -373,13 +373,13 @@ class Application(object): self.formatter.stop() def _run(self, argv): - # type: (Optional[List[str]]) -> None + # type: (List[str]) -> None self.initialize(argv) self.run_checks() self.report() - def run(self, argv=None): - # type: (Optional[List[str]]) -> None + def run(self, argv): + # type: (List[str]) -> None """Run our application. This method will also handle KeyboardInterrupt exceptions for the diff --git a/src/flake8/main/cli.py b/src/flake8/main/cli.py index 53f31e9..1bc9155 100644 --- a/src/flake8/main/cli.py +++ b/src/flake8/main/cli.py @@ -1,4 +1,5 @@ """Command-line implementation of flake8.""" +import sys from typing import List, Optional from flake8.main import application @@ -14,6 +15,9 @@ def main(argv=None): :param list argv: The arguments to be passed to the application for parsing. """ + if argv is None: + argv = sys.argv[1:] + app = application.Application() app.run(argv) app.exit() |
