Skip to content

Commit

Permalink
Merge pull request #1767 from PyCQA/update-select-docs
Browse files Browse the repository at this point in the history
communicate that --select is usually unnecessary
  • Loading branch information
asottile committed Dec 14, 2022
2 parents 780f64f + 837e819 commit 80e6cdf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
8 changes: 6 additions & 2 deletions docs/source/user/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -607,13 +607,14 @@ Options and their Descriptions

:ref:`Go back to index <top>`

**You usually do not need to specify this option as the default includes
all installed plugin codes.**

Specify the list of error codes you wish |Flake8| to report. Similarly to
:option:`--ignore`. You can specify a portion of an error code to get all
that start with that string. For example, you can use ``E``, ``E4``,
``E43``, and ``E431``.

This defaults to: ``E,F,W,C90``

Command-line example:

.. prompt:: bash
Expand Down Expand Up @@ -649,6 +650,9 @@ Options and their Descriptions

.. versionadded:: 4.0.0

**You usually do not need to specify this option as the default includes
all installed plugin codes.**

Specify a list of codes to add to the list of selected ones. Similar
considerations as in :option:`--select` apply here with regard to the
value.
Expand Down
1 change: 0 additions & 1 deletion src/flake8/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"*.egg",
)
IGNORE = ("E121", "E123", "E126", "E226", "E24", "E704", "W503", "W504")
SELECT = ("E", "F", "W", "C90")
MAX_LINE_LENGTH = 79
INDENT_SIZE = 4

Expand Down
14 changes: 9 additions & 5 deletions src/flake8/main/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,11 @@ def register_default_options(option_manager: OptionManager) -> None:
parse_from_config=True,
comma_separated_list=True,
help=(
f"Comma-separated list of error codes to enable. "
f"For example, ``--select=E4,E51,W234``. "
f"(Default: {','.join(defaults.SELECT)})"
"Limit the reported error codes to codes prefix-matched by this "
"list. "
"You usually do not need to specify this option as the default "
"includes all installed plugin codes. "
"For example, ``--select=E4,E51,W234``."
),
)

Expand All @@ -309,8 +311,10 @@ def register_default_options(option_manager: OptionManager) -> None:
parse_from_config=True,
comma_separated_list=True,
help=(
"Comma-separated list of error codes to add to the list "
"of selected ones. For example, ``--extend-select=E4,E51,W234``."
"Add additional error codes to the default ``--select``. "
"You usually do not need to specify this option as the default "
"includes all installed plugin codes. "
"For example, ``--extend-select=E4,E51,W234``."
),
)

Expand Down
2 changes: 1 addition & 1 deletion src/flake8/style_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self, options: argparse.Namespace) -> None:

self.selected = _select_ignore(
option=options.select,
default=defaults.SELECT,
default=(),
extended_default=options.extended_default_select,
extend=options.extend_select,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_decision_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def create_options(**kwargs):
kwargs.setdefault("ignore", None)
kwargs.setdefault("extend_select", None)
kwargs.setdefault("extend_ignore", None)
kwargs.setdefault("extended_default_select", [])
kwargs.setdefault("extended_default_select", ["C90", "F", "E", "W"])
kwargs.setdefault("extended_default_ignore", [])
kwargs.setdefault("disable_noqa", False)
return argparse.Namespace(**kwargs)
Expand Down

0 comments on commit 80e6cdf

Please sign in to comment.