8000 Verify plugin validation codes follow expected alphanumeric style · Issue #325 · PyCQA/flake8 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Verify plugin validation codes follow expected alphanumeric style #325
Closed
@asottile

Description

@asottile

In GitLab by @pjacock on Nov 27, 2019, 06:10

Spin out from discussion on https://gitlab.com/pycqa/flake8/merge_requests/385

https://gitlab.com/pycqa/flake8/blob/e571167161a42a5da052eaf247ab13ac0c56b7c6/src/flake8/defaults.py#L39 defines a REGEX which implicitly limits the allowed pattern for violation codes:

NOQA_INLINE_REGEXP = re.compile(
    # We're looking for items that look like this:
    # ``# noqa``
    # ``# noqa: E123``
    # ``# noqa: E123,W451,F921``
    # ``# noqa:E123,W451,F921``
    # ``# NoQA: E123,W451,F921``
    # ``# NOQA: E123,W451,F921``
    # ``# NOQA:E123,W451,F921``
    # We do not want to capture the ``: `` that follows ``noqa``
    # We do not care about the casing of ``noqa``
    # We want a comma-separated list of errors
    # https://regex101.com/r/4XUuax/2 full explenation of the regex
    r"# noqa(?::[\s]?(?P<codes>([A-Z]+[0-9]+(?:[,\s]+)?)+))?",
    re.IGNORECASE,
)

There should be a separate pattern for the violation codes (NOQA_INLINE_REGEXP could be defined using this), and this can be used to validate messages from plugins match this (and if not raise an error) before reporting them to the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0