Merge branch 'defect/469-improve-inline-noqa-regex-comment-and-documentation' into 'master'

Clearer docs, NOQA_INLINE_REGEXP comment - fixes #469

Closes #469

See merge request pycqa/flake8!262
This commit is contained in:
Anthony Sottile 2018-10-28 20:25:53 +00:00
commit 732a466ee8
3 changed files with 5 additions and 4 deletions

View file

@ -19,7 +19,7 @@ It also adds a few features:
- lines that contain a ``# noqa`` comment at the end will not issue warnings. - lines that contain a ``# noqa`` comment at the end will not issue warnings.
- you can ignore specific errors on a line with ``# noqa: <error>``, e.g., - you can ignore specific errors on a line with ``# noqa: <error>``, e.g.,
``# noqa: E234`` ``# noqa: E234``. Multiple codes can be given, separated by comma. The ``noqa`` token is case insensitive, the colon before the list of codes is required otherwise the part after ``noqa`` is ignored
- Git and Mercurial hooks - Git and Mercurial hooks
- extendable through ``flake8.extension`` and ``flake8.formatting`` entry - extendable through ``flake8.extension`` and ``flake8.formatting`` entry
points points

View file

@ -85,12 +85,13 @@ what is actually happening. In those cases, we can also do:
This will only ignore the error from pycodestyle that checks for lambda This will only ignore the error from pycodestyle that checks for lambda
assignments and generates an ``E731``. If there are other errors on the line assignments and generates an ``E731``. If there are other errors on the line
then those will be reported. then those will be reported. ``# noqa`` is case-insensitive, without the colon
the part after ``# noqa`` would be ignored.
.. note:: .. note::
If we ever want to disable |Flake8| respecting ``# noqa`` comments, we can If we ever want to disable |Flake8| respecting ``# noqa`` comments, we can
can refer to :option:`flake8 --disable-noqa`. refer to :option:`flake8 --disable-noqa`.
If we instead had more than one error that we wished to ignore, we could If we instead had more than one error that we wished to ignore, we could
list all of the errors with commas separating them: list all of the errors with commas separating them:

View file

@ -30,7 +30,7 @@ NOQA_INLINE_REGEXP = re.compile(
# ``# noqa: E123,W451,F921`` # ``# noqa: E123,W451,F921``
# ``# NoQA: E123,W451,F921`` # ``# NoQA: E123,W451,F921``
# ``# NOQA: E123,W451,F921`` # ``# NOQA: E123,W451,F921``
# We do not care about the ``: `` that follows ``noqa`` # We do not want to capture the ``: `` that follows ``noqa``
# We do not care about the casing of ``noqa`` # We do not care about the casing of ``noqa``
# We want a comma-separated list of errors # We want a comma-separated list of errors
r"# noqa(?:: (?P<codes>([A-Z][0-9]+(?:[,\s]+)?)+))?", r"# noqa(?:: (?P<codes>([A-Z][0-9]+(?:[,\s]+)?)+))?",