]>
crepu.dev Git - config.git/blob - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/flake8/plugins/reporter.py
1 """Functions for constructing the requested report plugin."""
2 from __future__
import annotations
7 from flake8
.formatting
.base
import BaseFormatter
8 from flake8
.plugins
.finder
import LoadedPlugin
10 LOG
= logging
.getLogger(__name__
)
14 reporters
: dict[str, LoadedPlugin
],
15 options
: argparse
.Namespace
,
17 """Make the formatter from the requested user options.
19 - if :option:`flake8 --quiet` is specified, return the ``quiet-filename``
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``
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"
34 format_plugin
= reporters
[format_name
]
37 "%r is an unknown formatter. Falling back to default.",
40 format_plugin
= reporters
["default"]
42 return format_plugin
.obj(options
)