summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/source/user/invocation.rst4
-rw-r--r--docs/source/user/options.rst33
-rw-r--r--src/flake8/main/options.py8
-rw-r--r--src/flake8/style_guide.py6
-rw-r--r--tests/unit/test_decision_engine.py1
-rw-r--r--tests/unit/test_style_guide.py1
6 files changed, 52 insertions, 1 deletions
diff --git a/docs/source/user/invocation.rst b/docs/source/user/invocation.rst
index d96d0f9..c469f37 100644
--- a/docs/source/user/invocation.rst
+++ b/docs/source/user/invocation.rst
@@ -107,6 +107,10 @@ And you should see something like:
--ignore=errors Comma-separated list of errors and warnings to ignore
(or skip). For example, ``--ignore=E4,E51,W234``.
(Default: E121,E123,E126,E226,E24,E704)
+ --extend-ignore=errors
+ Comma-separated list of errors and warnings to add to
+ the list of ignored ones. For example, ``--extend-
+ ignore=E4,E51,W234``.
--max-line-length=n Maximum allowed line length for the entirety of this
run. (Default: 79)
--select=errors Comma-separated list of errors and warnings to enable.
diff --git a/docs/source/user/options.rst b/docs/source/user/options.rst
index 4922c1a..1cbc22f 100644
--- a/docs/source/user/options.rst
+++ b/docs/source/user/options.rst
@@ -56,6 +56,8 @@ Index of Options
- :option:`flake8 --ignore`
+- :option:`flake8 --extend-ignore`
+
- :option:`flake8 --max-line-length`
- :option:`flake8 --select`
@@ -416,6 +418,37 @@ Options and their Descriptions
ignore = E121,E123
+.. option:: --extend-ignore=<errors>
+
+ :ref:`Go back to index <top>`
+
+ Specify a list of codes to add to the list of ignored ones. Similar
+ considerations as in :option:`--ignore` apply here with regard to the
+ value.
+
+ The difference to the :option:`--ignore` option is, that this option can be
+ used to selectively add individual codes without overriding the default
+ list entirely.
+
+ Command-line example:
+
+ .. prompt:: bash
+
+ flake8 --extend-ignore=E4,E51,W234 dir/
+
+ This **can** be specified in config files.
+
+ Example config file usage:
+
+ .. code-block:: ini
+
+ extend-ignore =
+ E4,
+ E51,
+ W234
+ extend-ignore = E4,E51,W234
+
+
.. option:: --max-line-length=<n>
:ref:`Go back to index <top>`
diff --git a/src/flake8/main/options.py b/src/flake8/main/options.py
index 131b714..c3ebb80 100644
--- a/src/flake8/main/options.py
+++ b/src/flake8/main/options.py
@@ -18,6 +18,7 @@ def register_default_options(option_manager):
- ``--format``
- ``--hang-closing``
- ``--ignore``
+ - ``--extend-ignore``
- ``--max-line-length``
- ``--select``
- ``--disable-noqa``
@@ -109,6 +110,13 @@ def register_default_options(option_manager):
)
add_option(
+ '--extend-ignore', metavar='errors', default='',
+ parse_from_config=True, comma_separated_list=True,
+ help='Comma-separated list of errors and warnings to add to the list'
+ ' of ignored ones. For example, ``--extend-ignore=E4,E51,W234``.',
+ )
+
+ add_option(
'--max-line-length', type='int', metavar='n',
default=defaults.MAX_LINE_LENGTH, parse_from_config=True,
help='Maximum allowed line length for the entirety of this run. '
diff --git a/src/flake8/style_guide.py b/src/flake8/style_guide.py
index 00eb1a5..e96acb8 100644
--- a/src/flake8/style_guide.py
+++ b/src/flake8/style_guide.py
@@ -3,6 +3,7 @@ import collections
import contextlib
import enum
import functools
+import itertools
import linecache
import logging
@@ -166,7 +167,10 @@ class DecisionEngine(object):
self.selected + self.enabled_extensions,
reverse=True,
))
- self.ignored = tuple(sorted(options.ignore, reverse=True))
+ self.ignored = tuple(sorted(
+ itertools.chain(options.ignore, options.extend_ignore),
+ reverse=True,
+ ))
self.using_default_ignore = set(self.ignored) == set(defaults.IGNORE)
self.using_default_select = (
set(self.selected) == set(defaults.SELECT)
diff --git a/tests/unit/test_decision_engine.py b/tests/unit/test_decision_engine.py
index 354dc69..810eff4 100644
--- a/tests/unit/test_decision_engine.py
+++ b/tests/unit/test_decision_engine.py
@@ -12,6 +12,7 @@ def create_options(**kwargs):
kwargs.setdefault('select', [])
kwargs.setdefault('extended_default_select', [])
kwargs.setdefault('ignore', [])
+ kwargs.setdefault('extend_ignore', [])
kwargs.setdefault('disable_noqa', False)
kwargs.setdefault('enable_extensions', [])
return optparse.Values(kwargs)
diff --git a/tests/unit/test_style_guide.py b/tests/unit/test_style_guide.py
index 84c47ff..c9005ab 100644
--- a/tests/unit/test_style_guide.py
+++ b/tests/unit/test_style_guide.py
@@ -14,6 +14,7 @@ def create_options(**kwargs):
kwargs.setdefault('select', [])
kwargs.setdefault('extended_default_select', [])
kwargs.setdefault('ignore', [])
+ kwargs.setdefault('extend_ignore', [])
kwargs.setdefault('disable_noqa', False)
kwargs.setdefault('enable_extensions', [])
return optparse.Values(kwargs)