]>
crepu.dev Git - config.git/blob - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/flake8/main/options.py
1 """Contains the logic for all of the default options for Flake8."""
2 from __future__
import annotations
6 from flake8
import defaults
7 from flake8
.options
.manager
import OptionManager
10 def stage1_arg_parser() -> argparse
.ArgumentParser
:
11 """Register the preliminary options on our OptionManager.
13 The preliminary options include:
15 - ``-v``/``--verbose``
20 - ``--enable-extensions``
22 parser
= argparse
.ArgumentParser(add_help
=False)
29 help="Print more information about what is happening in flake8. "
30 "This option is repeatable and will increase verbosity each "
31 "time it is repeated.",
35 "--output-file", default
=None, help="Redirect report to a file."
44 help="Provide extra config files to parse in addition to the files "
45 "found by Flake8 by default. These files are the last ones read "
46 "and so they take the highest precedence when multiple files "
47 "provide the same option.",
53 help="Path to the config file that will be the authoritative config "
54 "source. This will cause Flake8 to ignore all other "
55 "configuration files.",
62 help="Ignore all configuration files.",
65 # Plugin enablement options
68 "--enable-extensions",
69 help="Enable plugins and extensions that are otherwise disabled "
75 help="Require specific plugins to be installed before running",
82 """Type callback for the --jobs argument."""
84 def __init__(self
, arg
: str) -> None:
85 """Parse and validate the --jobs argument.
87 :param arg: The argument passed by argparse for validation
94 self
.n_jobs
= int(arg
)
96 raise argparse
.ArgumentTypeError(
97 f
"{arg!r} must be 'auto' or an integer.",
100 def __repr__(self
) -> str:
101 """Representation for debugging."""
102 return f
"{type(self).__name__}({str(self)!r})"
104 def __str__(self
) -> str:
105 """Format our JobsArgument class."""
106 return "auto" if self
.is_auto
else str(self
.n_jobs
)
109 def register_default_options(option_manager
: OptionManager
) -> None:
110 """Register the default options on our OptionManager.
112 The default options include:
118 - ``--extend-exclude``
123 - ``--extend-ignore``
124 - ``--per-file-ignores``
125 - ``--max-line-length``
126 - ``--max-doc-length``
129 - ``--extend-select``
139 add_option
= option_manager
.add_option
146 parse_from_config
=True,
147 help="Report only file names, or nothing. This option is repeatable.",
152 choices
=("auto", "always", "never"),
154 help="Whether to use color in output. Defaults to `%(default)s`.",
160 parse_from_config
=True,
161 help="Print total number of errors to standard output after "
168 default
=",".join(defaults
.EXCLUDE
),
169 comma_separated_list
=True,
170 parse_from_config
=True,
171 normalize_paths
=True,
172 help="Comma-separated list of files or directories to exclude. "
173 "(Default: %(default)s)",
180 parse_from_config
=True,
181 comma_separated_list
=True,
182 normalize_paths
=True,
183 help="Comma-separated list of files or directories to add to the list "
191 parse_from_config
=True,
192 comma_separated_list
=True,
193 help="Only check for filenames matching the patterns in this comma-"
194 "separated list. (Default: %(default)s)",
198 "--stdin-display-name",
200 help="The name used when reporting errors from code passed via stdin. "
201 "This is useful for editors piping the file contents to flake8. "
202 "(Default: %(default)s)",
205 # TODO(sigmavirus24): Figure out --first/--repeat
207 # NOTE(sigmavirus24): We can't use choices for this option since users can
208 # freely provide a format string and that will break if we restrict their
214 parse_from_config
=True,
216 f
"Format errors according to the chosen formatter "
217 f
"({', '.join(sorted(option_manager.formatter_names))}) "
218 f
"or a format string containing %%-style "
219 f
"mapping keys (code, col, path, row, text). "
221 f
"``--format=pylint`` or ``--format='%%(path)s %%(code)s'``. "
222 f
"(Default: %(default)s)"
229 parse_from_config
=True,
230 help="Hang closing bracket instead of matching indentation of opening "
237 parse_from_config
=True,
238 comma_separated_list
=True,
240 f
"Comma-separated list of error codes to ignore (or skip). "
241 f
"For example, ``--ignore=E4,E51,W234``. "
242 f
"(Default: {','.join(defaults.IGNORE)})"
249 parse_from_config
=True,
250 comma_separated_list
=True,
251 help="Comma-separated list of error codes to add to the list of "
252 "ignored ones. For example, ``--extend-ignore=E4,E51,W234``.",
256 "--per-file-ignores",
258 parse_from_config
=True,
259 help="A pairing of filenames and violation codes that defines which "
260 "violations to ignore in a particular file. The filenames can be "
261 "specified in a manner similar to the ``--exclude`` option and the "
262 "violations work similarly to the ``--ignore`` and ``--select`` "
270 default
=defaults
.MAX_LINE_LENGTH
,
271 parse_from_config
=True,
272 help="Maximum allowed line length for the entirety of this run. "
273 "(Default: %(default)s)",
281 parse_from_config
=True,
282 help="Maximum allowed doc line length for the entirety of this run. "
283 "(Default: %(default)s)",
289 default
=defaults
.INDENT_SIZE
,
290 parse_from_config
=True,
291 help="Number of spaces used for indentation (Default: %(default)s)",
297 parse_from_config
=True,
298 comma_separated_list
=True,
300 "Limit the reported error codes to codes prefix-matched by this "
302 "You usually do not need to specify this option as the default "
303 "includes all installed plugin codes. "
304 "For example, ``--select=E4,E51,W234``."
311 parse_from_config
=True,
312 comma_separated_list
=True,
314 "Add additional error codes to the default ``--select``. "
315 "You usually do not need to specify this option as the default "
316 "includes all installed plugin codes. "
317 "For example, ``--extend-select=E4,E51,W234``."
324 parse_from_config
=True,
326 help='Disable the effect of "# noqa". This will report errors on '
327 'lines with "# noqa" at the end.',
330 # TODO(sigmavirus24): Decide what to do about --show-pep8
335 parse_from_config
=True,
336 help="Show the source generate each error or warning.",
340 action
="store_false",
342 parse_from_config
=False,
343 help="Negate --show-source",
349 parse_from_config
=True,
350 help="Count errors.",
358 help='Exit with status code "0" even if there are errors.',
365 parse_from_config
=True,
367 help="Number of subprocesses to use to run checks in parallel. "
368 'This is ignored on Windows. The default, "auto", will '
369 "auto-detect the number of processors available to use. "
370 "(Default: %(default)s)",
376 parse_from_config
=True,
378 help="Write to stdout and output-file.",
387 help="Print benchmark information about this run of Flake8",
395 help="Print information necessary when preparing a bug report",