]>
crepu.dev Git - config.git/blob - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/flake8/options/parse_args.py
1 """Procedure for parsing args, config, loading plugins."""
2 from __future__
import annotations
5 from typing
import Sequence
8 from flake8
.main
import options
9 from flake8
.options
import aggregator
10 from flake8
.options
import config
11 from flake8
.options
import manager
12 from flake8
.plugins
import finder
17 ) -> tuple[finder
.Plugins
, argparse
.Namespace
]:
18 """Procedure for parsing args, config, loading plugins."""
19 prelim_parser
= options
.stage1_arg_parser()
21 args0
, rest
= prelim_parser
.parse_known_args(argv
)
22 # XXX (ericvw): Special case "forwarding" the output file option so
23 # that it can be reparsed again for the BaseFormatter.filename.
25 rest
.extend(("--output-file", args0
.output_file
))
27 flake8
.configure_logging(args0
.verbose
, args0
.output_file
)
29 cfg
, cfg_dir
= config
.load_config(
31 extra
=args0
.append_config
,
32 isolated
=args0
.isolated
,
35 plugin_opts
= finder
.parse_plugin_options(
38 enable_extensions
=args0
.enable_extensions
,
39 require_plugins
=args0
.require_plugins
,
41 raw_plugins
= finder
.find_plugins(cfg
, plugin_opts
)
42 plugins
= finder
.load_plugins(raw_plugins
, plugin_opts
)
44 option_manager
= manager
.OptionManager(
45 version
=flake8
.__version__
,
46 plugin_versions
=plugins
.versions_str(),
47 parents
=[prelim_parser
],
48 formatter_names
=list(plugins
.reporters
),
50 options
.register_default_options(option_manager
)
51 option_manager
.register_plugins(plugins
)
53 opts
= aggregator
.aggregate_options(option_manager
, cfg
, cfg_dir
, rest
)
55 for loaded
in plugins
.all_plugins():
56 parse_options
= getattr(loaded
.obj
, "parse_options", None)
57 if parse_options
is None:
60 # XXX: ideally we wouldn't have two forms of parse_options