Skip to content

Commit

Permalink
Merge master into issue-wemake-services#1172
Browse files Browse the repository at this point in the history
  • Loading branch information
adambenali committed Feb 29, 2020
2 parents 4f4ea38 + 4f58fcf commit e40c449
Show file tree
Hide file tree
Showing 29 changed files with 442 additions and 109 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ Semantic versioning in our case means:
- Forbids to use `:=` operator, it now reuses `WPS332` code
- Forbids to use positional only `/` arguments
- Forbids to have too many names imported from a single `from ... import`
- Forbids to use `continue` and `break` in `finally`
- Adds `__call__` to list of methods that should be on top #1125
- Allows `_` to be now used as a defined variable
- Removes `cognitive_complexity` dependency, now it is built in into our linter
- Adds baseline information for all complexity violation messages: `x > baseline`
- Changes how cognitive complexity is calculated
- Adds support for positional arguments in different checks
- Forbids to use `continue` and `break` in `finally`. It is a terrible practice, because
`finally` is implicitly called and can cause damage to logic with its implicitness.

### Bugfixes

Expand All @@ -50,7 +49,8 @@ Semantic versioning in our case means:
`ast.Continue`, `ast.Break`, and `ast.Raise` statements
- Fixes that cognitive complexity was ignoring `ast.AsyncFor` loops
- Fixes that annotation complexity was not reported for `async` functions
- Fixes that annotation complexity was not reported from lists
- Fixes that annotation complexity was not reported for lists
- Fixes that annotation complexity was not reported for `*` and `/` args
- Fixes bug when `TooManyPublicAttributesViolation`
was counting duplicate fields
- Fixes negated conditions `WPS504` was not reported for `if` expressions
Expand All @@ -66,12 +66,16 @@ Semantic versioning in our case means:
- Fixes `WPS204` reporting `self.` attribute access
- Fixes `WPS331` reporting cases that do require some extra steps before return
- Fixes `WPS612` not reporing `super()` calls without return
- Fixes `WPS404` not raising on wrong `*` and `/` defaults
- Fixes `WPS425` raising on `.get`, `getattr`, `setattr`,
and other builtin functions without keyword arguments

### Misc

- Changes how tests are executed
- Changes how coverage is calculated, adds `coverage-conditional-plugin`
- Adds how a violation can be deprecated
- Improves old function tests with `/` argument cases
- Adds `local-partial-types` to mypy config
- Uses `abc` stdlib's module to mark abstract base classes #1122
- Adds `python3.8` to the CI
Expand Down
10 changes: 9 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ It is also recommended to take a look at these resources:
- List of `flake8` [extensions](https://github.com/DmytroLitvinov/awesome-flake8-extensions)


## First steps

1. Fork [our repo](https://github.com/wemake-services/wemake-python-styleguide), here's the [guide on forking](https://help.github.com/en/github/getting-started-with-github/fork-a-repo)
2. [Clone your new repo](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) (forked repo) to have a local copy of the code
3. Apply the required changes! See developer docs on how to work with the code
4. Send a Pull Request to our original repo. Here's [the helpful guide](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request) on how to do that


## Developer's documentation

Make sure that you are familiar with [developer's documentation](https://wemake-python-stylegui.de/en/latest/pages/api/index.html).
Expand Down Expand Up @@ -54,7 +62,7 @@ Run `make test` to run everything we have!
#### Building on Windows

- Building directly in Windows does not work.
- Instead, use a Windows Subsystem for Linux (WSL) such as Ubuntu 18.04 LTS that you can get from the Microsoft Store.
- Instead, use a Windows Subsystem for Linux (WSL) such as Ubuntu 18.04 LTS that you can get from the Microsoft Store.
- Clone the project to a part of the WSL where Windows does not overwrite permissions, for example _directly to the home of the WSL_ (do `cd` and then `git clone`). That problem looks like [this](https://github.com/wemake-services/wemake-python-styleguide/issues/1007#issuecomment-562719702) and you can read more about why changing the permissons does not work [here](https://github.com/Microsoft/WSL/issues/81).

## Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

from wemake_python_styleguide.compat.constants import PY38
from wemake_python_styleguide.violations.complexity import (
TooComplexAnnotationViolation,
)
Expand All @@ -16,6 +17,26 @@ def some(arg: {0}):
...
"""

function_posonly_arg_template = """
def some(arg: {0}, /):
...
"""

function_args_template = """
def some(*args: {0}):
...
"""

function_kwargs_template = """
def some(**kwargs: {0}):
...
"""

function_kwarg_template = """
def some(*, arg: {0}):
...
"""

function_return_template = """
def some(arg) -> {0}:
...
Expand All @@ -31,6 +52,13 @@ class Test(object):
@pytest.mark.parametrize('template', [
annassign_template,
function_arg_template,
function_args_template,
function_kwargs_template,
function_kwarg_template,
pytest.param(
function_posonly_arg_template,
marks=pytest.mark.skipif(not PY38, reason='posonly appeared in 3.8'),
),
function_return_template,
class_field_template,
])
Expand Down Expand Up @@ -63,6 +91,13 @@ def test_correct_annotations(
@pytest.mark.parametrize('template', [
annassign_template,
function_arg_template,
function_args_template,
function_kwargs_template,
function_kwarg_template,
pytest.param(
function_posonly_arg_template,
marks=pytest.mark.skipif(not PY38, reason='posonly appeared in 3.8'),
),
function_return_template,
class_field_template,
])
Expand Down Expand Up @@ -99,6 +134,13 @@ def test_complex_annotations(
@pytest.mark.parametrize('template', [
annassign_template,
function_arg_template,
function_args_template,
function_kwargs_template,
function_kwarg_template,
pytest.param(
function_posonly_arg_template,
marks=pytest.mark.skipif(not PY38, reason='posonly appeared in 3.8'),
),
function_return_template,
class_field_template,
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import pytest

from wemake_python_styleguide.compat.constants import PY38

function_with_single_argument = 'def function(arg1): ...'
function_with_arguments = 'def function(arg1, arg2): ...'
function_with_args_kwargs = 'def function(*args, **kwargs): ...'
function_with_kwonly = 'def function(*, kwonly1, kwonly2=True): ...'
function_with_posonly = 'def function(arg1, arg2, /): ...'

method_without_arguments = """
class Test(object):
Expand All @@ -22,6 +25,11 @@ class Test(object):
def method(self, *args): ...
"""

method_with_single_posonly_arg = """
class Test(object):
def method(self, arg, /): ...
"""

method_with_single_kwargs = """
class Test(object):
def method(self, **kwargs): ...
Expand Down Expand Up @@ -83,10 +91,18 @@ def single_argument(request):
function_with_arguments,
function_with_args_kwargs,
function_with_kwonly,
pytest.param(
function_with_posonly,
marks=pytest.mark.skipif(not PY38, reason='posonly appeared in 3.8'),
),
method_with_single_argument,
method_with_single_args,
method_with_single_kwargs,
method_with_single_kwonly,
pytest.param(
method_with_single_posonly_arg,
marks=pytest.mark.skipif(not PY38, reason='posonly appeared in 3.8'),
),
classmethod_with_single_argument,
new_method_single_argument,
metaclass_with_single_argument,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

from wemake_python_styleguide.compat.constants import PY38
from wemake_python_styleguide.visitors.ast.complexity.function import (
FunctionComplexityVisitor,
TooManyArgumentsViolation,
Expand All @@ -11,6 +12,7 @@
lambda_with_single_argument = 'lambda arg1: ...'
lambda_with_default_argument = 'lambda arg1=None: ...'
lambda_with_single_args = 'lambda *args: ...'
lambda_with_posonly_args = 'lambda arg, /: ...'
lambda_with_single_kwargs = 'lambda **kwargs: ...'
lambda_with_single_kwonly = 'lambda *, kwonly=True: ...'

Expand All @@ -20,6 +22,10 @@
lambda_with_single_argument,
lambda_with_default_argument,
lambda_with_single_args,
pytest.param(
lambda_with_posonly_args,
marks=pytest.mark.skipif(not PY38, reason='posonly was added in 3.8'),
),
lambda_with_single_kwargs,
lambda_with_single_kwonly,
])
Expand All @@ -43,6 +49,10 @@ def test_correct_arguments_count(
lambda_with_single_argument,
lambda_with_default_argument,
lambda_with_single_args,
pytest.param(
lambda_with_posonly_args,
marks=pytest.mark.skipif(not PY38, reason='posonly was added in 3.8'),
),
lambda_with_single_kwargs,
lambda_with_single_kwonly,
])
Expand All @@ -66,6 +76,10 @@ def test_correct_arguments_count_custom_option(
lambda_with_single_argument,
lambda_with_default_argument,
lambda_with_single_args,
pytest.param(
lambda_with_posonly_args,
marks=pytest.mark.skipif(not PY38, reason='posonly was added in 3.8'),
),
lambda_with_single_kwargs,
lambda_with_single_kwonly,
])
Expand Down
Loading

0 comments on commit e40c449

Please sign in to comment.