The strictest and most opinionated python linter ever!
In this release we had a little focus on:
ImplicitInConditionViolation
from WPS336
to WPS514
ExplicitStringConcatViolation
uses WPS336
YieldMagicMethodViolation
from WPS435
to WPS611
xenon
as a dependency, it also checks for cyclomatic complexity,
but uses more advanced algorithm with better results--max-imported-names
option which is 50 by defaultStopIteration
inside generators1e10
instead of 1e+10
0xAB
instead of 0xab
r'\n'
instead of '\\n'
else if
instead of elif
try
bodies,
basically try
bodies with more than one statementWrongSlotsViolation
works, now (...) + value
is restricted
in favor of (..., *value)
j
prefix over J
for complex
numbers0
division, multiply, pow, addition, and substraction1
x + -2
, or y - -1
, or z -= -1
[0] * 2
__
and _____
_unused = 2
assert
statements in a function'a' + some_data
, use .format()
YieldInsideInitViolation
is named YieldMagicMethodViolation
and it also checks different magic methods in a classassert False
and other false-constantswhile False:
and other false-constantsopen()
outside of with
type()
for comparesprint(*[])
range(len(some))
, use enumerate(some)
insteadsum()
calls and replace them with loopsif some == []:
flake8-eradicate
version
and solves attrs
incompatible versions issueflake8-dosctrings
veresion
and solved pydocstyle
issueTryExceptMultipleReturnPathViolation
not tracking else
and finally
returns at the same timeTryExceptMultipleReturnPathViolation
works:
now handles break
and raise
statements as wellWrongLoopIterTypeViolation
not triggering
for generator expressions and empty tuplesWrongLoopIterTypeViolation
not triggering
for numbers (including negative), booleans, None
WrongLoopIterTypeViolation
positionWrongLoopIterTypeViolation
not triggering for compehensionsWrongSlotsViolation
not triggering
for comprehensions and incorrect __slots__
names and typesWrongSlotsViolation
not triggering
for invalid python
identifiers like __slots__ = ('123_slot',)
WrongSlotsViolation
triggering for subscriptsNestedClassViolation
and NestedFunctionViolation
not reporting
when placed deeply inside other nodesWrongUnpackingViolation
was not raised
for async for
and async with
nodesWrongUnpackingViolation
was not raised for comprehensionsx, y, z = x, z, y
was not recognized
as ReassigningVariableToItselfViolation
{1, True, 1.0}
was not recognised as a set with duplicates{(1, 2), (1, 2)}
was not recognised as a set with duplicates{*(1, 2), *(1, 2)}
was not recognised as a set with duplicates{1: 1, True: 1}
was not recognised as a dict with duplicatescomplex
numbers were always treated like magic,
now 1j
is allowed0.0
was treated as a magic number_
in module bodyWrongBaseClassViolation
not triggering
for nested nodes like class Test(call().length):
ComplexDefaultValueViolation
not triggering
for nested nodes like def func(arg=call().attr)
TooShortNameViolation
was not triggering for _x
and x_
yield from
noqa:
comments were reported as incorrectelse: return
were not reported as incorrectWPS507
sometimes were raising ValueError
return None
was not recognized as inconsistentstyles/
directory with style presets for tools we use and recommendbellybutton
to the list of other lintersnitpick
to sync the configurationflakehell
to create baseline
s for legacy integrationsxenon
CI checkcoverage
checks in deepsource@alias
checks that all aliases are validDirectMagicAttributeAccessViolation
is testedast.Starred
import-linter
instead of layer-linter
snake_case
in Enum
fieldsWPS400
and incorrect line numberWe had a really big problem: all violations inside best_practices
was messed up together with no clear structure.
We had to fix it before it is too late. So, we broke existing error codes. And now we can promise not to do it ever again.
We also have this nice migration guide for you to rename your violations with a script.
Z
error code to WPS
coderefactoring.py
oop.py
best_practices
to refactoring
, oop
, and consistency
wemake
formatter (using it now by default)OverusedStringViolation
for empty stringsOverusedStringViolation
InconsistentReturnVariableViolation
was raised twice0.11
--show-source
to the default recommended configurationautopep8
to CI to make sure that wps
is compatible with it--diff
mode works for flake8
Incorrect
to Wrong
where possibleIncorrectlyNestedTernaryViolation
to NestedTernaryViolation
IncorectLoopIterTypeViolation
to WrongLoopIterTypeViolation
This release is mostly targeted at writing better compares and conditions. We introduce a lot of new rules related to this topic improving: consistency, complexity, and general feel from your code.
In this release we have ported a lot of existing pylint
rules,
big cudos to the developers of this wonderful tool.
flake8-executable
as a dependencyflake8-rst-docstrings
as a dependencyflake8
breakpoint
functionawait
statementsbuiltins
lambda
slen(sized) > 0
and if len(sized)
style checksflag or flag
not some > 1
x == x > 0
>= 3
)if
conditions... and ... or ...
expressionc < b < a
instead of a > b and b > c
c < b < a
instead of a > b > c
in []
and in ()
, use sets or variables insteadisinstance(some, (A, B))
instead of isinstance(some, A) or isinstance(some, B)
isinstance(some (A,))
a == b or a == c
into a in {b, c}
and
to merge a != b and a != c
into a not in {b, c}
Z331
Z311
was not raising for multiple not in
casesAssign
and not AnnAssign
continue
was not triggering UselessReturningElseViolation
logics/
to logic/
since it is grammatically correctRedundant
to Useless
Comparison
to Compare
WrongConditionalViolation
to ConstantConditionViolation
ComplexDefaultValuesViolation
to ComplexDefaultValueViolation
UselessOperatorsVisitor
compat/
package, getting ready for python3.8
Makefile
This is mostly a supporting release with several new features and lots of bug fixes.
__getattr__
and __dir__
return
statementsio.py
Z310
for numbers like 0xE
await
_allowed_left_nodes
Z121
when using _
for unused var namesComplexDefaultValuesViolation
Z459
when a default value is an Ellipsis
py.typed
file in case someone will import our code,
now it will have types@final
decoratorstyping_extensions
package is usedblack
exclude
rule for flake8
checkpytest