Wemake Python Styleguide Versions Save

The strictest and most opinionated python linter ever!

0.12.3

4 years ago

Bugfixes

  • Fixes that formatting was failing sometimes when colours were not available
  • Fixes that 1 / number was not allowed
  • Fixes that % operator was allowed for 0 and 1

0.12.2

4 years ago

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

0.12.1

4 years ago

Bugfixes

  • Changes radon and pydocstyle versions for better resolution

Misc

  • Improves README.md with flakehell and nitpick mentions
  • Improves docs all accross the project

0.12.0

4 years ago

In this release we had a little focus on:

  1. Primitives and constants and how to use them
  2. Strings and numbers and how to write them
  3. OOP features
  4. Blocks and code structure, including variable scoping and overlaping variables
  5. Overused expressions and new complexity metrics

Features

  • Breaking: moves ImplicitInConditionViolation from WPS336 to WPS514
  • Breaking: now ExplicitStringConcatViolation uses WPS336
  • Breaking: moves YieldMagicMethodViolation from WPS435 to WPS611
  • 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 of 1e+10
  • Enforces to use big letters for hex numbers: 0xAB instead of 0xab
  • Enforces to use r'\n' instead of '\\n'
  • Forbids to have unicode escape characters inside binary strings
  • Forbids to use else if instead of elif
  • Forbids to have too long try bodies, basically try 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 over J for complex 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, or y - -1, or z -= -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 named YieldMagicMethodViolation 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 of with
  • 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)), use enumerate(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 solves attrs incompatible versions issue
  • Bumps flake8-dosctrings veresion and solved pydocstyle issue
  • Fixes TryExceptMultipleReturnPathViolation not tracking else and finally returns at the same time
  • Fixes how TryExceptMultipleReturnPathViolation works: now handles break and raise 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 invalid python identifiers like __slots__ = ('123_slot',)
  • Fixes WrongSlotsViolation triggering for subscripts
  • Fixes NestedClassViolation and NestedFunctionViolation not reporting when placed deeply inside other nodes
  • Fixes when WrongUnpackingViolation was not raised for async for and async with nodes
  • Fixes when WrongUnpackingViolation was not raised for comprehensions
  • Fixes that x, y, z = x, z, y was not recognized as ReassigningVariableToItselfViolation
  • 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, now 1j 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 like class Test(call().length):
  • Fixes ComplexDefaultValueViolation not triggering for nested nodes like def func(arg=call().attr)
  • Fixes TooShortNameViolation was not triggering for _x and x_
  • 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 raising ValueError
  • 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 create baselines 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 of layer-linter
  • Adds docs about CI integration
  • Now wheels are not universal
  • Updates docs about snake_case in Enum fields
  • Updates docs about WPS400 and incorrect line number

0.11.1

4 years ago

Bugfixes

  • Now using pygments as a direct dependency

0.11.0

4 years ago

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 to WPS code
  • Breaking: creates new violation group refactoring.py
  • Breaking: creates new violation group oop.py
  • Breaking: moving a lot of violations from best_practices to refactoring, oop, and consistency
  • 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 that wps is compatible with it
  • Ensures that --diff mode works for flake8
  • Renames Incorrect to Wrong where possible
  • Renames IncorrectlyNestedTernaryViolation to NestedTernaryViolation
  • Renames IncorectLoopIterTypeViolation to WrongLoopIterTypeViolation

0.10.0

4 years ago

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 lambdas
  • Forbids to use len(sized) > 0 and if 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 of a > b and b > c
  • Forces to use c < b < a instead of a > b > c
  • Forbids to use explicit in [] and in (), use sets or variables instead
  • Forces to write isinstance(some, (A, B)) instead of isinstance(some, A) or isinstance(some, B)
  • Forbids to use isinstance(some (A,))
  • Forces to merge a == b or a == c into a in {b, c} and to merge a != b and a != c into a not in {b, c}

Bugfixes

  • Fixes incorrect line number for Z331
  • Fixes that Z311 was not raising for multiple not in cases
  • Fixes a bunch of bugs for rules working with Assign and not AnnAssign
  • Fixes that continue was not triggering UselessReturningElseViolation

Misc

  • Renames logics/ to logic/ since it is grammatically correct
  • Renames Redundant to Useless
  • Renames Comparison to Compare
  • Renames WrongConditionalViolation to ConstantConditionViolation
  • Renames ComplexDefaultValuesViolation to ComplexDefaultValueViolation
  • Refactors UselessOperatorsVisitor
  • Adds compat/ package, getting ready for python3.8
  • Adds Makefile
  • A lot of minor dependency updates

0.9.1

4 years ago

Bugfixes

  • Fixes issue with pydocstyle>=4 by glueing its version to pydocstyle<4

0.9.0

4 years ago

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 like 0xE
  • 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 an Ellipsis

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 for flake8 check
  • Removed warnings from pytest

0.8.1

4 years ago

Bugfixes

  • Fixes how wps_context is calculated, so super() calls are now working