-
-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
6 changed files
with
218 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Github Actions | ||
-------------- | ||
|
||
.. image:: https://github.com/wemake-services/wemake-python-styleguide/workflows/wps/badge.svg | ||
:alt: Github Action badge | ||
:target: https://github.com/wemake-services/wemake-python-styleguide/actions | ||
|
||
Good news: we ship pre-built Github Action with this project. | ||
|
||
You can use it from the Github Marketplace: | ||
|
||
.. code:: yaml | ||
- name: wemake-python-styleguide | ||
uses: wemake-python-styleguide@latest | ||
You can also specify any version | ||
starting from ``0.12.5`` instead of the ``latest`` tag. | ||
|
||
Inputs | ||
~~~~~~ | ||
|
||
We also support custom path to be specified: | ||
|
||
.. code:: yaml | ||
- name: wemake-python-styleguide | ||
uses: wemake-python-styleguide@latest | ||
with: | ||
path: './your/custom/path' | ||
Outputs | ||
~~~~~~~ | ||
|
||
We also support ``outputs`` from the spec, so you can later | ||
pass the output of ``wemake-python-styleguide`` to somewhere else. | ||
For example to `reviewdog <https://github.com/reviewdog/reviewdog>`_ app. | ||
|
||
.. code:: yaml | ||
- name: wemake-python-styleguide | ||
uses: wemake-python-styleguide@latest | ||
with: | ||
path: './your/custom/path' | ||
- name: Custom reviewdog Action | ||
runs: echo "{{ steps.wemake-python-styleguide.outputs.output }}" | reviewdog -f pep8 | ||
Note, that Github Actions are currently in beta. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
legacy.rst | ||
flakehell.rst | ||
docker.rst | ||
github-actions.rst | ||
ci.rst | ||
stubs.rst | ||
pylint.rst | ||
|
115 changes: 115 additions & 0 deletions
115
tests/test_visitors/test_ast/test_blocks/test_overlap/test_same_name.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import pytest | ||
|
||
from wemake_python_styleguide.violations.best_practices import ( | ||
BlockAndLocalOverlapViolation, | ||
) | ||
from wemake_python_styleguide.visitors.ast.blocks import BlockVariableVisitor | ||
|
||
# Contexts: | ||
context = """ | ||
{0} | ||
{1} | ||
""" | ||
|
||
# Block statements: | ||
block_statement1 = 'from some import {0}, {1}' | ||
|
||
|
||
@pytest.mark.parametrize('block_statement', [ | ||
block_statement1, | ||
]) | ||
@pytest.mark.parametrize('local_statement', [ | ||
'{0} = func({0})', | ||
'{0} = {0}(arg)', | ||
'{0} = {0} + 1', | ||
'{0} = {0}.attr', | ||
'{0} = {0}["key"]', | ||
'{0} = d[{0}]', | ||
'{0} = d[{0}:1]', | ||
'{0}: type = func({0})', | ||
'{0}: type = {0}(arg)', | ||
'{0}: type = {0} + 1', | ||
'{0}: type = {0}.attr', | ||
'{0}: type = {0}["key"]', | ||
'{0}: type = d[{0}]', | ||
'{0}, {1} = {0}({1})', | ||
'{0}, {1} = {0} * {1}', | ||
'{1}, {0} = ({1}, {0})', | ||
'{1}, *{0} = ({1}, {0})', | ||
]) | ||
@pytest.mark.parametrize(('first_name', 'second_name'), [ | ||
('no_raise', 'used'), | ||
]) | ||
def test_reuse_no_overlap( | ||
assert_errors, | ||
parse_ast_tree, | ||
default_options, | ||
mode, | ||
block_statement, | ||
local_statement, | ||
first_name, | ||
second_name, | ||
): | ||
"""Ensures that overlaping variables does not exist.""" | ||
code = context.format( | ||
block_statement.format(first_name, second_name), | ||
local_statement.format(first_name, second_name), | ||
) | ||
tree = parse_ast_tree(mode(code)) | ||
|
||
visitor = BlockVariableVisitor(default_options, tree=tree) | ||
visitor.run() | ||
|
||
assert_errors(visitor, []) | ||
|
||
|
||
@pytest.mark.parametrize('block_statement', [ | ||
block_statement1, | ||
]) | ||
@pytest.mark.parametrize('local_statement', [ | ||
'{0} = func({1})', | ||
'{0} = {1}(arg)', | ||
'{0} = {1} + 1', | ||
'{0} = {1}.attr', | ||
'{0} = {1}["key"]', | ||
'{0} = d[{1}]', | ||
'{0} = d[{1}:1]', | ||
'{0}: {1}', | ||
'{0}: type = func({1})', | ||
'{0}: type = {1}(arg)', | ||
'{0}: type = {1} + 1', | ||
'{0}: type = {1}.attr', | ||
'{0}: type = {1}["key"]', | ||
'{0}: type = d[{1}]', | ||
'{0}, {1} = {0}({0})', | ||
'{0}, {1} = {1} * {1}', | ||
'{1}, {0} = ({0}, {0})', | ||
'{1}, *{0} = ({1}, {1})', | ||
]) | ||
@pytest.mark.parametrize(('first_name', 'second_name'), [ | ||
('no_raise', 'used'), | ||
]) | ||
def test_reuse_overlap( | ||
assert_errors, | ||
parse_ast_tree, | ||
default_options, | ||
mode, | ||
block_statement, | ||
local_statement, | ||
first_name, | ||
second_name, | ||
): | ||
"""Ensures that overlaping variables exist no.""" | ||
code = context.format( | ||
block_statement.format(first_name, second_name), | ||
local_statement.format(first_name, second_name), | ||
) | ||
tree = parse_ast_tree(mode(code)) | ||
|
||
visitor = BlockVariableVisitor(default_options, tree=tree) | ||
visitor.run() | ||
|
||
assert_errors(visitor, [BlockAndLocalOverlapViolation]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters