E901
|
SyntaxError or IndentationError |
Python raised a SyntaxError or IndentationError while parsing the file. The file cannot be executed in its current state. |
Critical
|
|
|
E902
|
IOError |
The file could not be read (IOError). This usually indicates a file permissions issue or a missing file. |
Critical
|
|
|
E999
|
SyntaxError |
A SyntaxError was raised while compiling the file. The file contains invalid Python syntax and cannot be imported or executed. |
Critical
|
|
|
F821
|
Undefined name |
Undefined name used in the code. The name has not been defined in any reachable scope and will raise a NameError at runtime. |
Critical
|
|
|
F823
|
Local variable referenced before assignment |
A local variable is referenced before it is assigned. This will always raise an UnboundLocalError at runtime. |
Critical
|
|
|
F831
|
Duplicate argument in function definition |
Duplicate argument name in a function definition. Python raises a SyntaxError for duplicate argument names at parse time. |
Critical
|
|
|
C901
|
Function too complex |
Function or method exceeds the configured McCabe complexity threshold (default 10). Highly complex functions are harder to test, review, and maintain securely. |
Warning
|
|
|
E101
|
Indentation contains mixed spaces and tabs |
Indentation contains mixed spaces and tabs. Mixed indentation is parsed differently by different tools and can cause subtle logic errors. |
Warning
|
|
|
E711
|
Comparison to None using == |
Comparison to None using == or !=. Use 'is None' or 'is not None' instead, as None is a singleton. |
Warning
|
|
|
E712
|
Comparison to True/False using == |
Comparison to True or False using == or !=. Use 'if cond:' or 'if not cond:' instead. |
Warning
|
|
|
E713
|
Test for membership should use 'not in' |
Test for membership should use 'not in x' instead of 'not x in'. The alternative form is clearer and less error-prone. |
Warning
|
|
|
E714
|
Test for identity should use 'is not' |
Test for object identity should use 'is not' instead of 'not … is'. The alternative form is clearer and less error-prone. |
Warning
|
|
|
E721
|
Type comparison using == |
Do not compare types using ==. Use isinstance() to support subclasses and avoid fragile type checks. |
Warning
|
|
|
E722
|
Bare except clause |
Do not use a bare except clause. Catching all exceptions silently can mask unexpected errors and security-relevant failures. |
Warning
|
|
|
E731
|
Lambda assignment |
Do not assign a lambda expression to a variable. Use a regular def statement instead, which is clearer and allows proper introspection. |
Warning
|
|
|
E741
|
Ambiguous variable name |
Do not use single-character ambiguous variable names 'l' (lowercase L), 'O' (uppercase O), or 'I' (uppercase I) which can be visually confused with 1 and 0. |
Warning
|
|
|
E742
|
Ambiguous class name |
Do not define classes named 'l', 'O', or 'I'. These single-character names are visually ambiguous with numerals. |
Warning
|
|
|
E743
|
Ambiguous function name |
Do not define functions named 'l', 'O', or 'I'. These single-character names are visually ambiguous with numerals. |
Warning
|
|
|
F402
|
Import shadowed by loop variable |
An import from line N was shadowed by a loop variable with the same name. This is likely a bug — the import becomes inaccessible inside the loop. |
Warning
|
|
|
F403
|
Star import used |
'from module import *' used. Star imports pollute the namespace and make it impossible to know which names are defined, potentially masking vulnerabilities. |
Warning
|
|
|
F404
|
Future import after other statements |
A 'from __future__ import' statement appears after non-future imports or other code. __future__ imports must be at the top of the file to take effect. |
Warning
|
|
|
F405
|
Name may be from star import |
A name may be undefined or may come from a star import. Because star imports are used, it is impossible to statically verify the name is defined. |
Warning
|
|
|
F811
|
Redefinition of unused name |
Redefinition of an unused name from a previous import. The first import is overwritten before being used, likely indicating a mistake. |
Warning
|
|
|
F822
|
Undefined name in __all__ |
A name listed in __all__ is not defined in the module. This will cause an AttributeError when the module is imported with 'from module import *'. |
Warning
|
|
|
F901
|
'raise NotImplemented' should be 'raise NotImplementedError' |
'raise NotImplemented' is almost certainly a bug. NotImplemented is a special singleton for use in binary special methods, not an exception. Use 'raise NotImplementedError' instead. |
Warning
|
|
|
W605
|
Invalid escape sequence |
Invalid escape sequence in a string literal (e.g. '\d', '\s'). In Python 3.12+ this is a SyntaxWarning and will become an error. Use raw strings (r'...') or double the backslash. |
Warning
|
|
|
E111
|
Indentation not a multiple of four |
Indentation is not a multiple of four spaces. Inconsistent indentation reduces code readability. |
Info
|
|
|
E112
|
Expected an indented block |
Expected an indented block. Indicates a structural indentation error that may signal missing code. |
Info
|
|
|
E113
|
Unexpected indentation |
Unexpected indentation (comment). A line is indented more than expected, indicating a possible structural error. |
Info
|
|
|
E114
|
Indentation not a multiple of four (comment) |
Indentation is not a multiple of four spaces (comment). Applies to comment lines in continuation blocks. |
Info
|
|
|
E115
|
Expected an indented block (comment) |
Expected an indented block (comment). A comment appears where an indented code block was expected. |
Info
|
|
|
E116
|
Unexpected indentation (comment) |
Unexpected indentation (comment). A comment is more indented than the surrounding code block. |
Info
|
|
|
E117
|
Over-indented |
Over-indented code. The statement is indented more than expected for the current block. |
Info
|
|
|
E121
|
Continuation line under-indented (hanging indent) |
Continuation line is under-indented for a hanging indent. The closing bracket or continuation does not align with the opening delimiter. |
Info
|
|
|
E122
|
Continuation line missing indentation |
Continuation line is missing indentation or is outdented relative to its opening bracket. |
Info
|
|
|
E123
|
Closing bracket does not match indentation |
Closing bracket does not match the indentation of the opening bracket's line. |
Info
|
|
|
E124
|
Closing bracket does not match visual indentation |
Closing bracket does not match visual indentation of the corresponding opening bracket. |
Info
|
|
|
E125
|
Continuation line with same indent as next logical line |
Continuation line has the same indentation as the next logical line, making it ambiguous. |
Info
|
|
|
E126
|
Continuation line over-indented (hanging indent) |
Continuation line is over-indented for a hanging indent. |
Info
|
|
|
E127
|
Continuation line over-indented (visual indent) |
Continuation line is over-indented for a visual indent. |
Info
|
|
|
E128
|
Continuation line under-indented (visual indent) |
Continuation line is under-indented for a visual indent. |
Info
|
|
|
E129
|
Visually indented line with same indent as next logical line |
Visually indented line with same indentation as the next logical line. |
Info
|
|
|
E131
|
Continuation line unaligned (hanging indent) |
Continuation line is unaligned for a block comment. |
Info
|
|
|
E133
|
Closing bracket is missing indentation |
Closing bracket is missing indentation. Not all flake8 versions report this code. |
Info
|
|
|
E201
|
Whitespace after opening bracket |
Whitespace immediately after an opening parenthesis, bracket, or brace. |
Info
|
|
|
E202
|
Whitespace before closing bracket |
Whitespace immediately before a closing parenthesis, bracket, or brace. |
Info
|
|
|
E203
|
Whitespace before punctuation |
Whitespace before a colon, semicolon, or comma. |
Info
|
|
|
E211
|
Whitespace before bracket |
Whitespace before a parenthesis or bracket (e.g. in function calls or subscripts). |
Info
|
|
|
E221
|
Multiple spaces before operator |
Multiple spaces before an operator, often used for alignment. Reduces readability of diffs. |
Info
|
|
|
E222
|
Multiple spaces after operator |
Multiple spaces after an arithmetic or assignment operator. |
Info
|
|
|
E223
|
Whitespace (tab) before operator |
A tab character appears before an operator, mixing whitespace types. |
Info
|
|
|
E224
|
Whitespace (tab) after operator |
A tab character appears after an operator, mixing whitespace types. |
Info
|
|
|
E225
|
Missing whitespace around operator |
Missing whitespace around an operator. Can reduce readability and occasionally cause misparse of complex expressions. |
Info
|
|
|
E226
|
Missing whitespace around arithmetic operator |
Missing whitespace around an arithmetic operator (+, -, *, /). |
Info
|
|
|
E227
|
Missing whitespace around bitwise/shift operator |
Missing whitespace around a bitwise or shift operator (|, &, ^, <<, >>). |
Info
|
|
|
E228
|
Missing whitespace around modulo operator |
Missing whitespace around the modulo operator (%). |
Info
|
|
|
E231
|
Missing whitespace after punctuation |
Missing whitespace after a comma, semicolon, or colon. |
Info
|
|
|
E241
|
Multiple spaces after comma |
Multiple spaces after a comma, often used for alignment. |
Info
|
|
|
E242
|
Tab after comma |
A tab character after a comma, mixing whitespace types. |
Info
|
|
|
E251
|
Unexpected spaces around keyword / parameter equals |
Unexpected spaces around keyword or default parameter equals sign. |
Info
|
|
|
E261
|
At least two spaces before inline comment |
At least two spaces before an inline comment are required by PEP 8. |
Info
|
|
|
E262
|
Inline comment should start with '# ' |
Inline comment should start with '# ' (a hash and a single space). |
Info
|
|
|
E265
|
Block comment should start with '# ' |
Block comment should start with '# ' (a hash and a single space), not '#!' or other variants. |
Info
|
|
|
E266
|
Too many leading '#' for block comment |
Block comment uses too many leading '#' characters (e.g. ## comment). |
Info
|
|
|
E271
|
Multiple spaces after keyword |
Multiple spaces after a keyword (if, for, while, etc.). |
Info
|
|
|
E272
|
Multiple spaces before keyword |
Multiple spaces before a keyword. |
Info
|
|
|
E273
|
Whitespace (tab) after keyword |
A tab character after a keyword. |
Info
|
|
|
E274
|
Whitespace (tab) before keyword |
A tab character before a keyword. |
Info
|
|
|
E275
|
Missing whitespace after keyword |
Missing whitespace after a keyword (e.g. if( instead of if (). |
Info
|
|
|
E301
|
Expected 1 blank line |
Expected 1 blank line before a nested definition, found 0. |
Info
|
|
|
E302
|
Expected 2 blank lines |
Expected 2 blank lines between top-level definitions, found fewer. |
Info
|
|
|
E303
|
Too many blank lines |
Too many blank lines (3 or more). PEP 8 recommends a maximum of 2 blank lines between definitions. |
Info
|
|
|
E304
|
Blank lines found after function decorator |
Blank lines found after a function decorator. There should be no blank lines between a decorator and its function. |
Info
|
|
|
E305
|
Expected 2 blank lines after end of function |
Expected 2 blank lines after the end of a function or class definition, found fewer. |
Info
|
|
|
E306
|
Expected 1 blank line before nested definition |
Expected 1 blank line before a nested definition (e.g. inner function or class), found 0. |
Info
|
|
|
E401
|
Multiple imports on one line |
Multiple module imports on one line (e.g. import os, sys). Each import should be on its own line. |
Info
|
|
|
E402
|
Module level import not at top of file |
Module level import is not at the top of the file. Imports after module-level code can cause subtle ordering issues. |
Info
|
|
|
E501
|
Line too long |
Line is too long (exceeds the configured maximum line length, default 79). Long lines reduce readability. |
Info
|
|
|
E502
|
Backslash is redundant between brackets |
Backslash continuation is redundant when inside brackets (parentheses, square brackets, or curly braces) which already imply line continuation. |
Info
|
|
|
E701
|
Multiple statements on one line (colon) |
Multiple statements on one line separated by a colon (e.g. if cond: pass). Each statement should be on its own line. |
Info
|
|
|
E702
|
Multiple statements on one line (semicolon) |
Multiple statements on one line separated by a semicolon. Each statement should be on its own line. |
Info
|
|
|
E703
|
Statement ends with a semicolon |
Statement ends with an unnecessary semicolon. |
Info
|
|
|
E704
|
Statement on same line as def |
Statement on the same line as def (e.g. def f(): return 1). The function body should be on the following line. |
Info
|
|
|
F401
|
Module imported but unused |
Module or name imported but never used in the file. Unused imports add noise and can indicate dead code. |
Info
|
|
|
F841
|
Local variable assigned but never used |
Local variable is assigned to but never used. Often indicates a bug where the result of a computation is discarded unintentionally. |
Info
|
|
|
W191
|
Indentation contains tabs |
Indentation contains tab characters. PEP 8 requires spaces for indentation, and tabs can cause misalignment across editors. |
Info
|
|
|
W291
|
Trailing whitespace |
Trailing whitespace at the end of a non-blank line. Trailing whitespace produces noisy diffs. |
Info
|
|
|
W292
|
No newline at end of file |
No newline at the end of the file. POSIX tools and version control systems expect a trailing newline. |
Info
|
|
|
W293
|
Whitespace on blank line |
Whitespace characters on a blank line. Produces noisy diffs and is invisible to most editors. |
Info
|
|
|
W391
|
Blank line at end of file |
One or more blank lines at the end of the file. |
Info
|
|
|
W503
|
Line break before binary operator |
Line break occurred before a binary operator. PEP 8 now recommends breaking before the operator (W504 is the conflicting rule). |
Info
|
|
|
W504
|
Line break after binary operator |
Line break occurred after a binary operator. PEP 8 recommends breaking before the operator (W503 is the conflicting rule). |
Info
|
|
|
W601
|
.has_key() deprecated |
dict.has_key() is deprecated in Python 3 and removed. Use 'key in dict' instead. |
Info
|
|
|
W602
|
Deprecated raise with two arguments |
Deprecated form of raising an exception (raise ExcType, value). Use 'raise ExcType(value)' instead. |
Info
|
|
|
W603
|
'<>' is deprecated |
Use of '<>' operator which is deprecated and removed in Python 3. Use '!=' instead. |
Info
|
|
|
W604
|
Backtick repr is deprecated |
Use of backtick for repr() is deprecated and removed in Python 3. Use repr() explicitly instead. |
Info
|
|
|