]> crepu.dev Git - config.git/blame - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/flake8/plugins/reporter.py
ActualizaciĆ³n de Readme
[config.git] / djavu-asus / elpy / rpc-venv / lib / python3.11 / site-packages / flake8 / plugins / reporter.py
CommitLineData
53e6db90
DC
1"""Functions for constructing the requested report plugin."""
2from __future__ import annotations
3
4import argparse
5import logging
6
7from flake8.formatting.base import BaseFormatter
8from flake8.plugins.finder import LoadedPlugin
9
10LOG = logging.getLogger(__name__)
11
12
13def make(
14 reporters: dict[str, LoadedPlugin],
15 options: argparse.Namespace,
16) -> BaseFormatter:
17 """Make the formatter from the requested user options.
18
19 - if :option:`flake8 --quiet` is specified, return the ``quiet-filename``
20 formatter.
21 - if :option:`flake8 --quiet` is specified at least twice, return the
22 ``quiet-nothing`` formatter.
23 - otherwise attempt to return the formatter by name.
24 - failing that, assume it is a format string and return the ``default``
25 formatter.
26 """
27 format_name = options.format
28 if options.quiet == 1:
29 format_name = "quiet-filename"
30 elif options.quiet >= 2:
31 format_name = "quiet-nothing"
32
33 try:
34 format_plugin = reporters[format_name]
35 except KeyError:
36 LOG.warning(
37 "%r is an unknown formatter. Falling back to default.",
38 format_name,
39 )
40 format_plugin = reporters["default"]
41
42 return format_plugin.obj(options)