]>
crepu.dev Git - config.git/blob - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/flake8/options/aggregator.py
1 """Aggregation function for CLI specified options and config file options.
3 This holds the logic that uses the collected and merged config files and
4 applies the user-specified command-line configuration on top of it.
6 from __future__
import annotations
11 from typing
import Sequence
13 from flake8
.options
import config
14 from flake8
.options
.manager
import OptionManager
16 LOG
= logging
.getLogger(__name__
)
19 def aggregate_options(
20 manager
: OptionManager
,
21 cfg
: configparser
.RawConfigParser
,
23 argv
: Sequence
[str] |
None,
24 ) -> argparse
.Namespace
:
25 """Aggregate and merge CLI and config file options."""
26 # Get defaults from the option parser
27 default_values
= manager
.parse_args([])
29 # Get the parsed config
30 parsed_config
= config
.parse_config(manager
, cfg
, cfg_dir
)
32 # store the plugin-set extended default ignore / select
33 default_values
.extended_default_ignore
= manager
.extended_default_ignore
34 default_values
.extended_default_select
= manager
.extended_default_select
36 # Merge values parsed from config onto the default values returned
37 for config_name
, value
in parsed_config
.items():
38 dest_name
= config_name
39 # If the config name is somehow different from the destination name,
40 # fetch the destination name from our Option
41 if not hasattr(default_values
, config_name
):
42 dest_val
= manager
.config_options_dict
[config_name
].dest
43 assert isinstance(dest_val
, str)
47 'Overriding default value of (%s) for "%s" with (%s)',
48 getattr(default_values
, dest_name
, None),
52 # Override the default values with the config values
53 setattr(default_values
, dest_name
, value
)
55 # Finally parse the command-line options
56 return manager
.parse_args(argv
, default_values
)