]> crepu.dev Git - config.git/blame - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/flake8/options/aggregator.py
ActualizaciĆ³n de Readme
[config.git] / djavu-asus / elpy / rpc-venv / lib / python3.11 / site-packages / flake8 / options / aggregator.py
CommitLineData
53e6db90
DC
1"""Aggregation function for CLI specified options and config file options.
2
3This holds the logic that uses the collected and merged config files and
4applies the user-specified command-line configuration on top of it.
5"""
6from __future__ import annotations
7
8import argparse
9import configparser
10import logging
11from typing import Sequence
12
13from flake8.options import config
14from flake8.options.manager import OptionManager
15
16LOG = logging.getLogger(__name__)
17
18
19def aggregate_options(
20 manager: OptionManager,
21 cfg: configparser.RawConfigParser,
22 cfg_dir: str,
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([])
28
29 # Get the parsed config
30 parsed_config = config.parse_config(manager, cfg, cfg_dir)
31
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
35
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)
44 dest_name = dest_val
45
46 LOG.debug(
47 'Overriding default value of (%s) for "%s" with (%s)',
48 getattr(default_values, dest_name, None),
49 dest_name,
50 value,
51 )
52 # Override the default values with the config values
53 setattr(default_values, dest_name, value)
54
55 # Finally parse the command-line options
56 return manager.parse_args(argv, default_values)