internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: wemake-services/wemake-python-styleguide

Issue:
False positive for Z121 when using `_` for unused var names
# Bug report

## What's wrong

This code triggers `Z121`:

```python
def logo_and_user():
    user, _ = User.objects.get_or_create(username='sobolevn')
    logo, _ = Logo.objects.get_or_create(username='sobolevn')  # here
```

Log: `test.py:4:11: Z121 Found usage of a variable marked as unused: _`
But it should not, since these variables are unused.

## How is that should be

It should not raise any `Z121` violations here.

## System information

I am using `8.0.1`

False positive Z309 for keys
# Bug report

<!--
Hi, thanks for submitting a bug. We appreciate that.

But, we will need some information about what's wrong to help you.
-->

## What's wrong

```python
def test(office, returned_item):
    assert returned_item['id'] == office.id
```

raises `Z309 Found reversed comparison order` violation

## How is that should be

It should not raise a violation. We use variables on both sides.

## System information

I am using `0.8.1` release.



Discussion:

Resolving patch:
diff --git a/wemake_python_styleguide/visitors/ast/functions.py b/wemake_python_styleguide/visitors/ast/functions.py
--- a/wemake_python_styleguide/visitors/ast/functions.py
+++ b/wemake_python_styleguide/visitors/ast/functions.py
@@ -127,6 +127,9 @@ def _maybe_update_variable(
         local_variables: Dict[str, List[LocalVariable]],
     ) -> None:
         if var_name in local_variables:
+            if var_name == UNUSED_VARIABLE:
+                if isinstance(getattr(sub_node, 'ctx', None), ast.Store):
+                    return
             local_variables[var_name].append(sub_node)
             return
 


Test patch:
diff --git a/tests/test_visitors/test_ast/test_functions/test_unused_variables.py b/tests/test_visitors/test_ast/test_functions/test_unused_variables.py
--- a/tests/test_visitors/test_ast/test_functions/test_unused_variables.py
+++ b/tests/test_visitors/test_ast/test_functions/test_unused_variables.py
@@ -56,6 +56,12 @@ def some_function():
         ...
 """
 
+correct_func_with_re_store_unused_variable = """
+def logo_and_user():
+    user, _ = some_tuple()
+    logo, _ = some_tuple()
+"""
+
 # Wrong:
 
 wrong_function = """
@@ -79,6 +85,12 @@ def some_method(self):
         print(_some)
 """
 
+wrong_using_unsedvariable = """
+def logo_and_user():
+    user, _ = some_tuple()
+    print(_)
+"""
+
 
 @pytest.mark.parametrize('code', [
     correct_module,
@@ -87,6 +99,7 @@ def some_method(self):
     correct_function_with_for,
     correct_function_with_exception,
     correct_function_with_unnamed_exception,
+    correct_func_with_re_store_unused_variable,
 ])
 def test_correct_variables(
     assert_errors,
@@ -108,6 +121,7 @@ def test_correct_variables(
     wrong_function,
     wrong_function_with_exception,
     wrong_method,
+    wrong_using_unsedvariable,
 ])
 def test_wrong_super_call(
     assert_errors,
Repository: wemake-services/wemake-python-styleguide

Issue:
Bug: Z459 should accept Ellipsis 
# Bug report

<!--
Hi, thanks for submitting a bug. We appreciate that.

But, we will need some information about what's wrong to help you.
-->

## What's wrong

False positive for `./returns/maybe.pyi:79:5: Z459 Found complex default value`
It should accept `ast.Ellipsis` as a default value, since it is a standard for `.pyi` files.

## How is that should be

```python
@final
class _Nothing(Maybe[Any]):
    _inner_value: None

    def __init__(self, inner_value: None = ...) -> None:
        ...
```


Discussion:
I can take care of this (: 
@phoolish-philomath awesome!

Resolving patch:
diff --git a/wemake_python_styleguide/violations/best_practices.py b/wemake_python_styleguide/violations/best_practices.py
--- a/wemake_python_styleguide/violations/best_practices.py
+++ b/wemake_python_styleguide/violations/best_practices.py
@@ -1623,8 +1623,8 @@ class ComplexDefaultValuesViolation(ASTViolation):
     Forbids to use complex defaults.
 
     Anything that is not a ``ast.Name``, ``ast.Attribute``, ``ast.Str``,
-    ``ast.NameConstant``, ``ast.Tuple``, ``ast.Bytes`` or ``ast.Num`` should
-    be moved out from defaults.
+    ``ast.NameConstant``, ``ast.Tuple``, ``ast.Bytes``, ``ast.Num``
+    or ``ast.Ellipsis`` should be moved out from defaults.
 
     Reasoning:
         It can be tricky. Nothing stops you from making database calls or http
diff --git a/wemake_python_styleguide/visitors/ast/functions.py b/wemake_python_styleguide/visitors/ast/functions.py
--- a/wemake_python_styleguide/visitors/ast/functions.py
+++ b/wemake_python_styleguide/visitors/ast/functions.py
@@ -107,6 +107,7 @@ class FunctionDefinitionVisitor(BaseNodeVisitor):
         ast.Tuple,
         ast.Bytes,
         ast.Num,
+        ast.Ellipsis,
     )
 
     def _check_used_variables(


Test patch:
diff --git a/tests/test_visitors/test_ast/test_functions/test_complex_default_values.py b/tests/test_visitors/test_ast/test_functions/test_complex_default_values.py
--- a/tests/test_visitors/test_ast/test_functions/test_complex_default_values.py
+++ b/tests/test_visitors/test_ast/test_functions/test_complex_default_values.py
@@ -9,6 +9,12 @@
     FunctionDefinitionVisitor,
 )
 
+function_with_ellipse_default = """
+def __init__(self, inner_value: None = ...) -> None:
+    ...
+"""
+
+
 function_with_defaults = """
 def __init__(
     self,
@@ -65,3 +71,19 @@ def test_correct_function_defaults(
     visitor.run()
 
     assert_errors(visitor, [])
+
+
+def test_ellipse_correct_default(
+    assert_errors,
+    assert_error_text,
+    parse_ast_tree,
+    default_options,
+    mode,
+):
+    """Testing that ellipse is accepted as a correct default value."""
+    tree = parse_ast_tree(mode(function_with_ellipse_default))
+
+    visitor = FunctionDefinitionVisitor(default_options, tree=tree)
+    visitor.run()
+
+    assert_errors(visitor, [])
Repository: wemake-services/wemake-python-styleguide

Issue:
Add `reveal_type` to forbidden functions
Now it is not recognised as invalid.
However, there's no reason to use it in production.


Discussion:
Hello, @sobolevn. I can do it.
But I'm a newbie in python world and can you tell me more about this task?
Thank you =)
@serhii73 add this function here: https://github.com/wemake-services/wemake-python-styleguide/blob/master/wemake_python_styleguide/constants.py#L15

That's all.
plz assign this issue to me on the GitHub UI. Thanks =)

Resolving patch:
diff --git a/wemake_python_styleguide/constants.py b/wemake_python_styleguide/constants.py
--- a/wemake_python_styleguide/constants.py
+++ b/wemake_python_styleguide/constants.py
@@ -46,6 +46,9 @@
 
     # OOP:
     'staticmethod',
+
+    # Mypy:
+    'reveal_type',
 ))
 
 #: List of module metadata we forbid to use.


Test patch:
Repository: wemake-services/wemake-python-styleguide

Issue:
Wrong and correct examples of nested annotations mixed up in docs for Union type
# Bug report

<!--
Hi, thanks for submitting a bug. We appreciate that.

But, we will need some information about what's wrong to help you.
-->

## What's wrong

From ``NestedAnnotationsViolation`` class docstring:
```
Example::
        # Correct:
        Literal[1, 2, 3, "foo", 5, None]
        Union[Union[int, str], float]

        # Wrong:
        Literal[Literal[Literal[1, 2, 3], "foo"], 5, None]
        Union[int, str, float]
```
There is a mistake: correct and wrong examples for ``Union`` type are mixed up. If I run flake8 passing it a file which contains ``Union[int, str, float]`` annotation, no error will be raised. And for ``Union[Union[int, str], float]`` WPS702 is raised. Both are expected behaviour I guess, just a mismatch in documentation.
## How is that should be

```
Example::
        # Correct:
        Literal[1, 2, 3, "foo", 5, None]
        Union[int, str, float]

        # Wrong:
        Literal[Literal[Literal[1, 2, 3], "foo"], 5, None]
        Union[Union[int, str], float]
```
<!--

  Love wemake-python-styleguide? ❤️
  Do you want your bugs to be solved faster?

  Please consider supporting our collective:
👉  https://opencollective.com/wemake-python-styleguide/donate

-->



Discussion:
@ko3luhbka can you please send a PR with the fix?
@sobolevn  yes, of course. Just wasn't shure about the issue workflow.

Resolving patch:
diff --git a/wemake_python_styleguide/violations/annotations.py b/wemake_python_styleguide/violations/annotations.py
--- a/wemake_python_styleguide/violations/annotations.py
+++ b/wemake_python_styleguide/violations/annotations.py
@@ -79,11 +79,11 @@ class NestedAnnotationsViolation(ASTViolation):
     Example::
         # Correct:
         Literal[1, 2, 3, "foo", 5, None]
-        Union[Union[int, str], float]
+        Union[int, str, float]
 
         # Wrong:
         Literal[Literal[Literal[1, 2, 3], "foo"], 5, None]
-        Union[int, str, float]
+        Union[Union[int, str], float]
 
     .. versionadded:: 0.13.0
 


Test patch:
Repository: wemake-services/wemake-python-styleguide

Issue:
WPS324 false-positive with nested functions
# Bug report

<!--
Hi, thanks for submitting a bug. We appreciate that.

But, we will need some information about what's wrong to help you.
-->

## What's wrong

This code produces false positive `WPS324`:

```python
def test():
    def decorator():
        return
    return decorator
```

<!-- Describe what is not working. Please, attach a traceback. -->

## How is that should be

These two returns are completely different cases. We should check `.wps_context` of the node.
See: 
- https://github.com/wemake-services/wemake-python-styleguide/blob/master/wemake_python_styleguide/visitors/ast/keywords.py#L133
- https://github.com/wemake-services/wemake-python-styleguide/blob/b43e738c4527219f03c2eec420fe2e20cfd4c8cc/wemake_python_styleguide/logic/nodes.py#L29

<!--

  Love wemake-python-styleguide? ❤️
  Do you want your bugs to be solved faster?

  Please consider supporting our collective:
👉  https://opencollective.com/wemake-python-styleguide/donate

-->



Discussion:
I'd like to fix it
Thanks! Assigned 🙂 

Resolving patch:
diff --git a/wemake_python_styleguide/visitors/ast/keywords.py b/wemake_python_styleguide/visitors/ast/keywords.py
--- a/wemake_python_styleguide/visitors/ast/keywords.py
+++ b/wemake_python_styleguide/visitors/ast/keywords.py
@@ -121,7 +121,8 @@ def _iterate_returning_values(
         returns: List[ast.Return] = []
         has_values = False
         for sub_node in ast.walk(node):
-            if isinstance(sub_node, returning_type):
+            context_node = get_context(sub_node)
+            if isinstance(sub_node, returning_type) and context_node == node:
                 if sub_node.value:
                     has_values = True
                 returns.append(sub_node)


Test patch:
diff --git a/tests/test_visitors/test_ast/test_keywords/test_consistency_returning/test_consistency_return.py b/tests/test_visitors/test_ast/test_keywords/test_consistency_returning/test_consistency_return.py
--- a/tests/test_visitors/test_ast/test_keywords/test_consistency_returning/test_consistency_return.py
+++ b/tests/test_visitors/test_ast/test_keywords/test_consistency_returning/test_consistency_return.py
@@ -97,6 +97,13 @@ def function():
     return
 """
 
+wrong_example4 = """
+def function():
+    def decorator():
+        return
+    return decorator
+"""
+
 double_wrong_return1 = """
 def function():
     if some:
@@ -117,6 +124,7 @@ def function():
     wrong_example1,
     wrong_example2,
     wrong_example3,
+    wrong_example4,
 ])
 def test_wrong_return_statement(
     assert_errors,
Repository: wemake-services/wemake-python-styleguide

Issue:
Specific case for ParametersIndentationViolation
I have a lot of violations fro my pytest fixtures like this one
```pytest
@pytest.mark.parametrize(
    ("is_verified", "status_code"),
    [
        (True, web.HTTPOk.status_code),
        (False, web.HTTPUnauthorized.status_code),
    ])
```
It's unclear from doc examples how to fix it. Documentation contains only simple examples.

I suggest adding one complex example like the above one.


Discussion:
```python
@pytest.mark.parametrize(('is_verified', 'status_code'), [
     (True, web.HTTPOk.status_code),
     (False, web.HTTPUnauthorized.status_code),
])
```

Will you please update the docs?

Resolving patch:
diff --git a/wemake_python_styleguide/violations/consistency.py b/wemake_python_styleguide/violations/consistency.py
--- a/wemake_python_styleguide/violations/consistency.py
+++ b/wemake_python_styleguide/violations/consistency.py
@@ -754,6 +754,13 @@ def my_function(
             last_item,
         ], end='')
 
+        # Correct complex case:
+
+        @pytest.mark.parametrize(('boolean_arg', 'string_arg'), [
+             (True, "string"),
+             (False, "another string"),
+        ])
+
     Everything else is considered a violation.
     This rule checks: lists, sets, tuples, dicts, calls,
     functions, methods, and classes.


Test patch:
Repository: wemake-services/wemake-python-styleguide

Issue:
False positive implicit yield violation
# Bug report

<!--
Hi, thanks for submitting a bug. We appreciate that.

But, we will need some information about what's wrong to help you.
-->

## What's wrong
With common function to split iterable by chunks WPS raises `ImplicitYieldFromViolation`
<!-- Describe what is not working. Please, attach a traceback. -->
```
def chunks(value, chunk_size):
    """Yield successive n-sized chunks from l."""
    for index in range(0, len(value), chunk_size):
        yield value[index:index + chunk_size]
```

## How is that should be
`ImplicitYieldFromViolation` should be raised only if no other operations with iterable item.
<!-- Describe how it should work. -->

<!--

  Love wemake-python-styleguide? ❤️
  Do you want your bugs to be solved faster?

  Please consider supporting our collective:
👉  https://opencollective.com/wemake-python-styleguide/donate

-->

Incorrect message for WPS349
# Bug report

<!--
Hi, thanks for submitting a bug. We appreciate that.

But, we will need some information about what's wrong to help you.
-->

## What's wrong

Code:

```python
'eman'[None:None:-1]
```

Output:

```
  1:1      WPS349 Found redundant subscript slice: <_ast.Subscript object at 0x106f57e50>
  'eman'[None:None:-1]
  ^
```

## How is that should be

It should be `WPS349 Found redundant subscript slice`

<!-- Describe how it should work. -->

<!--

  Love wemake-python-styleguide? ❤️
  Do you want your bugs to be solved faster?

  Please consider supporting our collective:
👉  https://opencollective.com/wemake-python-styleguide/donate

-->




Discussion:
What about 

```python
yield from (
    value[index:index + chunk_size]
    for index in range(0, len(value), chunk_size)
)
```

?
Less readable in my taste. But if no other choices I will use it. Thanks.
Thanks for raising this, I guess we need to update the violation docs about this case.


Resolving patch:
diff --git a/wemake_python_styleguide/violations/consistency.py b/wemake_python_styleguide/violations/consistency.py
--- a/wemake_python_styleguide/violations/consistency.py
+++ b/wemake_python_styleguide/violations/consistency.py
@@ -1882,7 +1882,7 @@ class RedundantSubscriptViolation(ASTViolation):
 
     """
 
-    error_template = 'Found redundant subscript slice: {0}'
+    error_template = 'Found redundant subscript slice'
     code = 349
 
 
diff --git a/wemake_python_styleguide/violations/refactoring.py b/wemake_python_styleguide/violations/refactoring.py
--- a/wemake_python_styleguide/violations/refactoring.py
+++ b/wemake_python_styleguide/violations/refactoring.py
@@ -1049,9 +1049,14 @@ class ImplicitYieldFromViolation(ASTViolation):
         # Correct:
         yield from some()
 
+        yield from (
+            value[index:index + chunk_size]
+            for index in range(0, len(value), chunk_size)
+        )
+
         # Wrong:
-        for item in some():
-            yield item
+        for index in chunk:
+            yield index
 
     .. versionadded:: 0.13.0
 


Test patch:
Repository: wemake-services/wemake-python-styleguide

Issue:
WPS114 Found underscored name pattern failes on cornercase
# Bug report

<!--
Hi, thanks for submitting a bug. We appreciate that.

But, we will need some information about what's wrong to help you.
-->

## What's wrong
```python
# Correct:
star_wars_episode2 = 'awesome!'

# Incorrect
star_wars_2episode = "also awesome"
```
```
test.py
     1:   1 WPS114 Found underscored name pattern: star_wars_2episode [wemake-python-styleguide]
  star_wars_2episode = ""
  ^
```
<!-- Describe what is not working. Please, attach a traceback. -->

## How is that should be
Checker should ignore numbers concatenated with strings.


There was a question [here](https://github.com/wemake-services/wemake-python-styleguide/issues/205#issuecomment-427339146) but with no answer


Discussion:
> Checker should ignore numbers concatenated with strings.

Why do you think so? 

The whole idea about this rule was to force `sw_episode2` instead of `sw_2episode`
You can also try `sw_2_episode`
My personal problem is short abbreviations like `1c` or `360security`.  I cant start a variable with a digit but I can't name it like `contract_1c`  `firewall_360security`
Let's make a PR with the experiment to allow this? 

Resolving patch:
diff --git a/wemake_python_styleguide/logic/naming/logical.py b/wemake_python_styleguide/logic/naming/logical.py
--- a/wemake_python_styleguide/logic/naming/logical.py
+++ b/wemake_python_styleguide/logic/naming/logical.py
@@ -7,7 +7,7 @@
 
 # Used to specify a pattern which checks variables and modules for underscored
 # numbers in their names:
-_UNDERSCORED_NUMBER_PATTERN: Final = re.compile(r'.+\D\_\d+(\D|$)')
+_UNDERSCORED_NUMBER_PATTERN: Final = re.compile(r'.+\D\_\d+($|[^a-zA-Z0-9])')
 
 
 def is_wrong_name(name: str, to_check: Iterable[str]) -> bool:
@@ -167,6 +167,9 @@ def does_contain_underscored_number(name: str) -> bool:
     >>> does_contain_underscored_number('iso123_456')
     False
 
+    >>> does_contain_underscored_number('contract_1c')
+    False
+
     >>> does_contain_underscored_number('star_wars_episode_2')
     True
 


Test patch:
Repository: wemake-services/wemake-python-styleguide

Issue:
Bump flake8-builtins
New version of `flake8-builtins` is released: `1.5.2`

We need to update our dependency here: https://github.com/wemake-services/wemake-python-styleguide/blob/master/pyproject.toml#L63
Here's how to do it: https://github.com/wemake-services/wemake-python-styleguide/blob/master/CONTRIBUTING.md#dependencies
Bump flake8-builtins
New version of `flake8-builtins` is released: `1.5.2`

We need to update our dependency here: https://github.com/wemake-services/wemake-python-styleguide/blob/master/pyproject.toml#L63
Here's how to do it: https://github.com/wemake-services/wemake-python-styleguide/blob/master/CONTRIBUTING.md#dependencies


Discussion:

Resolving patch:
diff --git a/wemake_python_styleguide/options/config.py b/wemake_python_styleguide/options/config.py
--- a/wemake_python_styleguide/options/config.py
+++ b/wemake_python_styleguide/options/config.py
@@ -155,7 +155,7 @@ class _Option(object):
 
     long_option_name: str
     default: ConfigValuesTypes
-    help: str
+    help: str  # noqa: A003
     type: Optional[str] = 'int'  # noqa: A003
     parse_from_config: bool = True
     action: str = 'store'


Test patch:
Repository: wemake-services/wemake-python-styleguide

Issue:
Add Exceptions for TooShortNameViolation
# Rule request

I tend to set min-name-length to 2 in my projects [default is 3]

Then, I get a WPS111 error, for example, for `import numpy as np`

## Thesis

I feel it would be great if there were an allowlist for names that are too short given the configuration but still allowed.

## Reasoning

No matter if min-name-length is 2 or 3, there will always be common idiomatic names that are short.

Examples: np (numpy), df (common name when working with only one Pandas DataFrame), sns (Seaborn), sa (sqlalchemy), ...

Alternative: Provide a default allowlist with common short names that do not cause an error.


Discussion:

Resolving patch:
diff --git a/wemake_python_styleguide/constants.py b/wemake_python_styleguide/constants.py
--- a/wemake_python_styleguide/constants.py
+++ b/wemake_python_styleguide/constants.py
@@ -386,6 +386,17 @@
     'TYPE_CHECKING',
 ))
 
+#: List of commonly used aliases
+ALIAS_NAMES_WHITELIST: Final = frozenset((
+    'np',
+    'pd',
+    'df',
+    'plt',
+    'sns',
+    'tf',
+    'cv',
+))
+
 # Internal variables
 # ==================
 
diff --git a/wemake_python_styleguide/logic/naming/logical.py b/wemake_python_styleguide/logic/naming/logical.py
--- a/wemake_python_styleguide/logic/naming/logical.py
+++ b/wemake_python_styleguide/logic/naming/logical.py
@@ -1,6 +1,9 @@
 from typing import Iterable
 
-from wemake_python_styleguide.constants import UNUSED_PLACEHOLDER
+from wemake_python_styleguide.constants import (
+    ALIAS_NAMES_WHITELIST,
+    UNUSED_PLACEHOLDER,
+)
 from wemake_python_styleguide.logic.naming import access
 
 
@@ -109,7 +112,13 @@ def is_too_short_name(
     >>> is_too_short_name('xy', min_length=2, trim=True)
     False
 
+    >>> is_too_short_name('np', min_length=3)
+    False
+
     """
+    if name in ALIAS_NAMES_WHITELIST:
+        return False
+
     if access.is_unused(name):
         return False
 


Test patch:
Repository: wemake-services/wemake-python-styleguide

Issue:
Add "wrapper" to NESTED_FUNCTIONS_WHITELIST?
# Rule request

## Thesis and reasoning

Decorators are often created inside functions. These decorators are then supposed to be used on top of other functions, which means they must accept one, and also that they will often create and return a new function by wrapping the original one. It's a level-3 nesting of functions. Maybe WPS430 should be relaxed, or `NESTED_FUNCTIONS_WHITELIST` could include another name like `wrapper`?

Code example:

```python
from functools import wraps


def python(versions):
    """Run through multiple Python versions."""

    def decorator(func):
        @wraps(func)
        def wrapper(context, *args, **kwargs):
            for version in versions:
                # do things with version and context
                func(context, *args, **kwargs)

        return wrapper

    return decorator


@python(["3.6", "3.7", "3.8"])
def task(context):
    ...
```

What do you think 🙂 ?



Discussion:
This might be a good one! 👍 

Resolving patch:
diff --git a/wemake_python_styleguide/constants.py b/wemake_python_styleguide/constants.py
--- a/wemake_python_styleguide/constants.py
+++ b/wemake_python_styleguide/constants.py
@@ -278,6 +278,7 @@
 NESTED_FUNCTIONS_WHITELIST: Final = frozenset((
     'decorator',
     'factory',
+    'wrapper',
 ))
 
 #: List of allowed ``__future__`` imports.


Test patch: