Releases: wemake-services/wemake-python-styleguide
Version 0.12.4
Bugfixes
- Fixes bug with
nitpick
colors and new files API - Updates
flake8-docstrings
Version 0.12.3
Bugfixes
- Fixes that formatting was failing sometimes when colours were not available
- Fixes that
1 / number
was not allowed - Fixes that
%
operator was allowed for0
and1
Version 0.12.2
Features
- Adds
reveal_type
to the list of forbidden functions WPS517
now allows to use non-string keys inside**{}
,
so this is allowed:Users.objects.get(**{User.USERNAME_FIELD: username})
Bugfixes
- Fixes that
{**a, **b}
was reported as duplicate hash items
Version 0.12.1
Bugfixes
- Changes
radon
andpydocstyle
versions for better resolution
Misc
- Improves
README.md
withflakehell
andnitpick
mentions - Improves docs all accross the project
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
Version 0.11.1
Bugfixes
- Now using
pygments
as a direct dependency
Version 0.11.0 aka The New Violation Codes
We 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.
Features
- Breaking: replaces
Z
error code toWPS
code - Breaking: creates new violation group
refactoring.py
- Breaking: creates new violation group
oop.py
- Breaking: moving a lot of violations
frombest_practices
torefactoring
,oop
, andconsistency
- Adds new
wemake
formatter (using it now by default)
Bugfixes
- Fixes error message of
OverusedStringViolation
for empty strings - Now does not count string annotations as strings for
OverusedStringViolation
- Fixes
InconsistentReturnVariableViolation
was raised twice
Misc
- Adds migration guide to
0.11
- Improves legacy guide
- Adds
--show-source
to the default recommended configuration - Adds better docs about auto-formatters
- Adds
autopep8
to CI to make sure thatwps
is compatible with it - Ensures that
--diff
mode works forflake8
- Renames
Incorrect
toWrong
where possible - Renames
IncorrectlyNestedTernaryViolation
toNestedTernaryViolation
- Renames
IncorectLoopIterTypeViolation
toWrongLoopIterTypeViolation
Version 0.10.0 aka The Great Compare
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.
Features
- Adds
flake8-executable
as a dependency - Adds
flake8-rst-docstrings
as a dependency - Validates options that are passed with
flake8
- Forbids to use module level mutable constants
- Forbids to over-use strings
- Forbids to use
breakpoint
function - Limits yield tuple lengths
- Forbids to have too many
await
statements - Forbids to subclass lowercase
builtins
- Forbids to have useless
lambda
s - Forbids to use
len(sized) > 0
andif len(sized)
style checks - Forbids to use repeatable conditions:
flag or flag
- Forbids to write conditions like
not some > 1
- Forbids to use heterogenous compares like
x == x > 0
- Forbids to use complex compare with several items (
>= 3
) - Forbids to have class variables that are shadowed by instance variables
- Forbids to use ternary expressions inside
if
conditions - Forces to use ternary instead of
... and ... or ...
expression - Forces to use
c < b < a
instead ofa > b and b > c
- Forces to use
c < b < a
instead ofa > b > c
- Forbids to use explicit
in []
andin ()
, use sets or variables instead - Forces to write
isinstance(some, (A, B))
instead ofisinstance(some, A) or isinstance(some, B)
- Forbids to use
isinstance(some (A,))
- Forces to merge
a == b or a == c
intoa in {b, c}
and
to mergea != b and a != c
intoa not in {b, c}
Bugfixes
- Fixes incorrect line number for
Z331
- Fixes that
Z311
was not raising for multiplenot in
cases - Fixes a bunch of bugs for rules working with
Assign
and notAnnAssign
- Fixes that
continue
was not triggeringUselessReturningElseViolation
Misc
- Renames
logics/
tologic/
since it is grammatically correct - Renames
Redundant
toUseless
- Renames
Comparison
toCompare
- Renames
WrongConditionalViolation
toConstantConditionViolation
- Renames
ComplexDefaultValuesViolation
toComplexDefaultValueViolation
- Refactors
UselessOperatorsVisitor
- Adds
compat/
package, getting ready forpython3.8
- Adds
Makefile
- A lot of minor dependency updates
Version 0.9.1
Bugfixes
- Fixes issue with
pydocstyle>=4
by glueing its version topydocstyle<4
Version 0.9.0
This is mostly a supporting release with several new features
and lots of bug fixes.
Features
- Forbids to use magic module methods
__getattr__
and__dir__
- Forbids to use multiline conditions
- Forbids local variables that are only used in
return
statements
Bugfixes
- Fixes module names for modules like
io.py
- Fixes false positive
Z310
for numbers like0xE
- Fixes false positive for compare ordering with
await
- Fixes problem with missing
_allowed_left_nodes
- Fixes problem false positive for
Z121
when using_
for unused var names - Fixes false positive for negative number in default values
- Fixes error text for
ComplexDefaultValuesViolation
- Fixes problem with false positive for
Z459
when a default value is anEllipsis
Misc
- Adds
py.typed
file in case someone will import our code,
now it will have types - Adds several missing
@final
decorators - Enforces typing support
- Refactors how
typing_extensions
package is used - Adds docs about
black
- Adds big "Star" button
- Multiple dependencies update
- Better
exclude
rule forflake8
check - Removed warnings from
pytest