Version 0.12.0
In this release we had a little focus on:
- Primitives and constants and how to use them
- Strings and numbers and how to write them
- OOP features
- Blocks and code structure,
including variable scoping and overlaping variables - Overused expressions and new complexity metrics
Features
- Breaking: moves
ImplicitInConditionViolation
fromWPS336
toWPS514
- Breaking: now
ExplicitStringConcatViolation
usesWPS336
- Breaking: moves
YieldMagicMethodViolation
fromWPS435
toWPS611
- Adds
xenon
as a dependency, it also checks for cyclomatic complexity,
but uses more advanced algorithm with better results - Forbids to have modules with too many imported names
configured by--max-imported-names
option which is 50 by default - Forbids to raise
StopIteration
inside generators - Forbids to have incorrect method order inside classes
- Forbids to make some magic methods async
- Forbids to use meaningless zeros in float, binary, octal, hex,
and expanentional numbers - Enforces to use
1e10
instead of1e+10
- Enforces to use big letters for hex numbers:
0xAB
instead of0xab
- Enforces to use
r'\n'
instead of'\\n'
- Forbids to have unicode escape characters inside binary strings
- Forbids to use
else if
instead ofelif
- Forbids to have too long
try
bodies,
basicallytry
bodies with more than one statement - Forbids to overlap local and block variables
- Forbids to use block variables after the block definitions
- Changes how
WrongSlotsViolation
works, now(...) + value
is restricted
in favor of(..., *value)
- Forbids to have explicit unhashable types in sets and dicts
- Forbids to define useless overwritten methods
- Enforces
j
prefix overJ
forcomplex
numbers - Forbids overused expressions
- Forbids explicit
0
division, multiply, pow, addition, and substraction - Fordids to pow, multiply, or divide by
1
- Forbids to use expressions like
x + -2
, ory - -1
, orz -= -1
- Forbids to multiply lists like
[0] * 2
- Forbids to use variable names like
__
and_____
- Forbids to define unused variables explicitly:
_unused = 2
- Forbids to shadow outer scope variables with local ones
- Forbids to have too many
assert
statements in a function - Forbids to have explicit string contact:
'a' + some_data
, use.format()
- Now
YieldInsideInitViolation
is namedYieldMagicMethodViolation
and it also checks different magic methods in a class - Forbids to use
assert False
and other false-constants - Forbids to use
while False:
and other false-constants - Forbids to use
open()
outside ofwith
- Forbids to use
type()
for compares - Forbids to have consecutive expressions with too deep access level
- Forbids to have too many public instance attributes
- Forbids to use pointless star operations:
print(*[])
- Forbids to use
range(len(some))
, useenumerate(some)
instead - Forbids to use implicit
sum()
calls and replace them with loops - Forbids to compare with the falsy constants like
if some == []:
Bugfixes
- Bumps
flake8-eradicate
version
and solvesattrs
incompatible versions issue - Bumps
flake8-dosctrings
veresion
and solvedpydocstyle
issue - Fixes
TryExceptMultipleReturnPathViolation
not trackingelse
andfinally
returns at the same time - Fixes how
TryExceptMultipleReturnPathViolation
works:
now handlesbreak
andraise
statements as well - Fixes
WrongLoopIterTypeViolation
not triggering
for generator expressions and empty tuples - Fixes
WrongLoopIterTypeViolation
not triggering
for numbers (including negative), booleans,None
- Fixes
WrongLoopIterTypeViolation
position - Fixes
WrongLoopIterTypeViolation
not triggering for compehensions - Fixes
WrongSlotsViolation
not triggering
for comprehensions and incorrect__slots__
names and types - Fixes
WrongSlotsViolation
not triggering
for invalidpython
identifiers like__slots__ = ('123_slot',)
- Fixes
WrongSlotsViolation
triggering for subscripts - Fixes
NestedClassViolation
andNestedFunctionViolation
not reporting
when placed deeply inside other nodes - Fixes when
WrongUnpackingViolation
was not raised
forasync for
andasync with
nodes - Fixes when
WrongUnpackingViolation
was not raised for comprehensions - Fixes that
x, y, z = x, z, y
was not recognized
asReassigningVariableToItselfViolation
- Fixes that
{1, True, 1.0}
was not recognised as a set with duplicates - Fixes that
{(1, 2), (1, 2)}
was not recognised as a set with duplicates - Fixes that
{*(1, 2), *(1, 2)}
was not recognised as a set with duplicates - Fixes that
{1: 1, True: 1}
was not recognised as a dict with duplicates - Fixes that
complex
numbers were always treated like magic,
now1j
is allowed - Fixes that
0.0
was treated as a magic number - Fixes that it was possible to use
_
in module body - Fixes
WrongBaseClassViolation
not triggering
for nested nodes likeclass Test(call().length):
- Fixes
ComplexDefaultValueViolation
not triggering
for nested nodes likedef func(arg=call().attr)
- Fixes
TooShortNameViolation
was not triggering for_x
andx_
- Fixes that some magic method were allowed to be generators
- Fixes that some magic method were allowed to contain
yield from
- Fixes bug when some correct
noqa:
comments were reported as incorrect - Fixes bug when some
else: return
were not reported as incorrect - Fixes bug when
WPS507
sometimes were raisingValueError
- Fixes bug when
return None
was not recognized as inconsistent
Misc
- Adds
styles/
directory with style presets for tools we use and recommend - Adds
bellybutton
to the list of other linters - Documents how to use
nitpick
to sync the configuration - Documents how to use
flakehell
to createbaseline
s for legacy integrations - Improves tests for binary, octal, hex, and expanetional numbers
- Adds new
xenon
CI check - Now handles exceptions in our own code, hope to never see them!
- Now uses
coverage
checks in deepsource - Now
@alias
checks that all aliases are valid - Changes how presets are defined
- Improves how
DirectMagicAttributeAccessViolation
is tested - Refactors a lot of tests to tests
ast.Starred
- Refactors a lot of tests to have less tests with the same logical coverage
- We now use
import-linter
instead oflayer-linter
- Adds docs about CI integration
- Now wheels are not universal
- Updates docs about
snake_case
inEnum
fields - Updates docs about
WPS400
and incorrect line number