Discuss defining violation codes in plugin development guide
http://flake8.pycqa.org/en/latest/plugin-development/index.html does not appear to describe conventions for defining violation codes in a flake8 plugin.
Here I am using #
to denote a single digit.
Historically these appear to have taken the form of a single letter prefix and three digits (e.g. E101
), following the core set of violations provided by flake8 itself (examples below). Each each plugin ought to define unique codes, and given the way the select/ignore options work this is best achieved by using a unique prefix.
In https://gitlab.com/pycqa/flake8/issues/337 @sigmavirus24 said since flake8 v3.0 "doesn't enforce 4 character long violation codes", and suggested RST
as a prefix for the example being discussed.
The plugin development guide should cover this, explaining that each plugin ought to define unique codes using a alphabetic prefix followed by three digits.
(Three digits is my assumption given how the --select
and --ignore
commands work, presumably --ignore R
would ignore R###
but not RST###
, which would be ignored using --ignore RST
and vice versa).
The plugin development guide should also recommend listing the codes defined in the main README file for the plugin (surprisingly many existing plugins do not do this!).
Current Examples:
The following prefixes are already in use, and are not an exhaustive list:
-
A
:-
flake8-author
defines codesA400
,A401
andA402
https://github.com/jparise/flake8-author/blob/1.1.2/flake8_author.py#L84
-
-
C
:-
flake8-coding
definesC101
toC103
https://github.com/tk0miya/flake8-coding -
flake8-commas
defines codesC812
toC816
https://github.com/flake8-commas/flake8-commas/blob/master/README.rst -
mccabe
definesC901
https://github.com/PyCQA/mccabe/blob/0.6.1/mccabe.py#L232
-
-
D
:-
flake8-deprecated
definesD001
https://github.com/gforcada/flake8-deprecated/blob/1.2/flake8_deprecated.py#L11 -
flake8-docstring
uses codesD###
frompydocstyle
http://www.pydocstyle.org/en/latest/error_codes.html
-
-
E
: Provided by flake8 frompycodestyle
errorsE###
https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes -
F
: Provided by flake8 forpyflakes
codesF###
http://flake8.pycqa.org/en/latest/user/error-codes.html -
I
: Used by:-
flake8-import-order
definesI100
,I101
,I201
https://github.com/PyCQA/flake8-import-order -
flake8-tidy-imports
definesI200
andI201
https://github.com/adamchainz/flake8-tidy-imports/blob/1.0.6/flake8_tidy_imports.py#L52 -
flake8-isort
definesI001
toI004
https://github.com/gforcada/flake8-isort/blob/2.2.1/flake8_isort.py#L24
-
-
M
:-
flake8-mock
definesM001
https://github.com/aleGpereira/flake8-mock/blob/v0.2/flake8_mock.py#L20 -
flake8-mutable
definesM511
https://github.com/ebeweber/flake8-mutable/blob/v1.2.0/mutable_defaults.py#L25
-
-
N
:-
flake8-naming
definesN8##
codes https://github.com/PyCQA/pep8-naming
-
-
O
:-
flake8-ownership
definesO100
toO102
https://bitbucket.org/decafjoe/flake8-ownership/
-
-
P
:-
flake8-string-format
definesP10#
,P20#
andP30#
codes https://github.com/xZise/flake8-string-format
-
-
Q
:-
flake8-quotes
definesQ000
andQ001
https://github.com/zheller/flake8-quotes/blob/0.11.0/flake8_quotes/init.py#L180 -
flake8-quotes2
definesQ100
andQ101
codes https://github.com/txomon/flake8-quotes/blob/v0.0.1/flake8_quotes.py#L37 -
flake8-sql
definesQ44#
codes https://github.com/pgjones/flake8-sql
-
-
R
:-
radon
plugin definesR701
https://github.com/rubik/radon/blob/v2.0.2/radon/complexity.py#L115 -
flake8-regex
reports user-definedR###
codes https://github.com/aristiden7o/flake8-regex/blob/master/flake8_regex.py
-
-
S
:-
flake8-sorted-keys
definesS001
https://github.com/yevhen-m/flake8-sorted-keys/blob/v0.1.0/flake8_sorted_keys/checker.py#L10 -
flake8-pep3101
also definesS001
https://github.com/gforcada/flake8-pep3101/blob/1.1/flake8_pep3101.py#L10 -
flake8-strict
definesS100
andS101
https://github.com/smarkets/flake8-strict -
flake8-snippets
also definesS100
https://github.com/bitlabstudio/flake8-snippets/blob/master/flake8_snippets/flake8_snippets.py
-
-
T
:-
flake8-print
defines codesT001
,T003
andT101
https://github.com/JBKahn/flake8-print/blob/2.0.2/flake8_print.py#L6 -
flake8-debugger
definesT002
https://github.com/JBKahn/flake8-debugger/blob/master/flake8_debugger.py#L7 -
flake8-todo
defines codeT000
https://github.com/schlamar/flake8-todo/blob/master/flake8_todo.py#L16 -
flake8-builtins
also defines codeT002
https://github.com/vikingco/flake8-builtins/blob/1.3.1/flake8_builtins.py#L8 -
flake8-pytest
also defines codeT003
https://github.com/vikingco/flake8-pytest/blob/1.3/flake8_pytest.py#L8 -
flake8-libfaketime
defines codeT004
https://github.com/vikingco/flake8-libfaketime/blob/1.1/flake8_libfaketime.py#L8 -
flake8-module-import
defines codeT005
https://github.com/vikingco/flake8-module-import/blob/1.1/flake8_module_imports.py#L8 -
flake8-ugettext-alias
definesT006
https://github.com/vikingco/flake8-ugettext-alias/blob/1.1/flake8_ugettext_alias.py#L8 -
flake8-translation-activate
also definesT006
https://github.com/vikingco/flake8-translation-activate/blob/master/flake8_translation_activate.py#L8 -
flake8-user-model
definesT007
https://github.com/vikingco/flake8-user-model/blob/1.1/flake8_user_model.py#L8 -
flake8-tuple
definesT801
https://github.com/ar4s/flake8_tuple/blob/0.2.13/flake8_tuple.py#L16
-
-
W
: Provided by flake8 forpycodestyle
warningsW###
https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
Note multiple clashes, especially in the T###
codes, including one some from the same author/team(!).