8000 Support hyphens in error codes · Issue #1568 · PyCQA/flake8 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Support hyphens in error codes #1568
Closed
Closed
@jarshwah

Description

@jarshwah

describe the request

I'd like to be able to use hyphens in error codes so that I can have readable error codes that are name-spaced. For example, here's a list of some error codes we're currently using:

COMPANY-UNIT-TESTS-FILEPATH
COMPANY-FUNCTIONAL-TESTS-FILEPATH
COMPANY-PRINT-STATEMENTS
COMPANY-MOCK-ASSERT-METHODS

These codes work fine with noqa directives. The only place they don't seem to work is in flake8 configuration files (such as setup.cfg). That is, the following config file crashes flake8:

[flake8]
per-file-ignores =
    tests/test_flake8_plugin.py:COMPANY-UNIT-TESTS-FILEPATH

With the error:

There was a critical error during execution of Flake8:
Expected `per-file-ignores` to be a mapping from file exclude patterns to ignore codes.

Configured `per-file-ignores` setting:

    tests/test_flake8_plugin.py:COMPANY-UNIT-TESTS-FILEPATH

I believe it comes down to this line:

(re.compile(r"[A-Z]+[0-9]*(?=$|\s|,)"), _CODE),

The fix could be a simple update of the regex. I will put a patch together shortly to demonstrate a potential fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0