repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.oop import AsyncMagicMethodViolation from wemake_python_styleguide.visitors.ast.classes.methods import ( WrongMethodVisitor, ) sync_method = """ class Example: def {0}(self): ... """ async_method = """ class Example: async def {0}(self): ... """ @py...
[])
assert_*
collection
tests/test_visitors/test_ast/test_classes/test_methods/test_async_magic_methods.py
test_correct_async_magic_used
76
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide import constants from wemake_python_styleguide.violations.consistency import VagueImportViolation from wemake_python_styleguide.visitors.ast.imports import WrongImportVisitor import_template = 'import {0}' from_import_template = 'from mod import {0}' alias_import_template1 ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_imports/test_vague_imports.py
test_fixed_vague_method_name_import
80
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.oop import BuiltinSubclassViolation from wemake_python_styleguide.visitors.ast.classes.classdef import ( WrongClassDefVisitor, ) class_with_base = 'class TestClass({0}): ...' enum_with_primitive1 = 'class First({0}, enum.Enum): ...' enum_with_primitive2 = 'c...
[])
assert_*
collection
tests/test_visitors/test_ast/test_classes/test_base_classes/test_base_builtin_classes.py
test_regular_subclass
79
null
wemake-services/wemake-python-styleguide
from contextlib import suppress import pytest from wemake_python_styleguide.constants import SPECIAL_ARGUMENT_NAMES_WHITELIST from wemake_python_styleguide.violations.naming import ( ReservedArgumentNameViolation, TrailingUnderscoreViolation, ) from wemake_python_styleguide.visitors.ast.naming.validation impo...
[])
assert_*
collection
tests/test_visitors/test_ast/test_naming/test_naming_rules/test_reserved_argument.py
test_correct_argument_name
78
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( ConstantCompareViolation, ReversedComplexCompareViolation, ) from wemake_python_styleguide.visitors.ast.compares import CompareSanityVisitor chained_compares1 = '0 < {0} < {1}' chained_compares2 = '{0} > {1} > 0' chained_compares3 = '...
[])
assert_*
collection
tests/test_visitors/test_ast/test_compares/test_literal.py
test_non_literal
39
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.oop import BuggySuperContextViolation from wemake_python_styleguide.visitors.ast.classes.methods import ( BuggySuperCallVisitor, ) error_dict_comprehension = """ {super().make_key(it): make_value(it) for it in items} """ error_set_comprehension = """ ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_classes/test_buggy_super.py
test_correct_super_context
120
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( MeaninglessNumberOperationViolation, UselessOperatorsViolation, ) from wemake_python_styleguide.visitors.ast.operators import ( UselessOperatorsVisitor, ) assignment = 'constant = {0}' assignment_addition = 'constant = x + {0}' as...
[])
assert_*
collection
tests/test_visitors/test_ast/test_operators/test_useless_operators_before_numbers.py
test_plus_sign_before_numbers_valid
105
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyAssertsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.function import ( FunctionComplexityVisitor, ) function_without_asserts = 'def function(): ...' function_with_asserts = """ def function(): if some: ...
option_values.max_asserts)
assert_*
complex_expr
tests/test_visitors/test_ast/test_complexity/test_function/test_asserts_count.py
test_asserts_wrong_count
74
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( AwaitInLoopViolation, ) from wemake_python_styleguide.visitors.ast.loops import ( WrongStatementInLoopVisitor, ) simple_for_loop = """ async def foo(): for _ in range(10): await some() """ list_comprehension = """ asyn...
[])
assert_*
collection
tests/test_visitors/test_ast/test_loops/test_loops/test_await_in_loop.py
test_good_await_in_loop
180
null
wemake-services/wemake-python-styleguide
from wemake_python_styleguide.options import config def test_option_asdict_no_none(): """Ensure that `None` is not returned from `asdict_no_none()`.""" opt = config._Option( # noqa: SLF001 '--foo', default=False, action='store_true', type=None, help='', ) asser...
opt.asdict_no_none()
assert
func_call
tests/test_options/test_option_rules.py
test_option_asdict_no_none
29
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( WrongLoopIterTypeViolation, ) from wemake_python_styleguide.visitors.ast.loops import ( WrongLoopDefinitionVisitor, ) for_loop_template = """ def function(): for index in {0}: ... """ list_comprehension_template = """ def...
[])
assert_*
collection
tests/test_visitors/test_ast/test_loops/test_loops/test_iter_type.py
test_iter_correct_type
126
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( DottedRawImportViolation, ) from wemake_python_styleguide.visitors.ast.imports import WrongImportVisitor regular_import = 'import {0}' regular_import_with_alias = 'import {0} as alias' from_import = 'from {0} import some_module' from_impo...
[])
assert_*
collection
tests/test_visitors/test_ast/test_imports/test_dotted_raw_import.py
test_correct_flat_import
73
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( LambdaInsideLoopViolation, ) from wemake_python_styleguide.visitors.ast.loops import WrongLoopVisitor lambda_inside_for_loop = """ def wrapper(): for index in range(10): print(lambda: index) """ nested_lambda_inside_for_lo...
[])
assert_*
collection
tests/test_visitors/test_ast/test_loops/test_loops/test_lambda_in_loop.py
test_correct_lambda_body
146
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.constants import SPECIAL_ARGUMENT_NAMES_WHITELIST from wemake_python_styleguide.visitors.ast.naming.validation import ( WrongNameVisitor, ) lambda_first_argument = 'lambda {0}: ...' function_first_argument = 'def function({0}): ...' method_first_argument = """ class Te...
[])
assert_*
collection
tests/test_visitors/test_ast/test_naming/test_first_arguments.py
test_correct_first_arguments
52
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.oop import ( WrongClassBodyContentViolation, ) from wemake_python_styleguide.visitors.ast.classes.classdef import ( WrongClassBodyVisitor, ) class_body_template = """ class ClassWithBody: {0} """ @pytest.mark.parametrize( 'code', [ '"...
[])
assert_*
collection
tests/test_visitors/test_ast/test_classes/test_wrong_class_body.py
test_body_correct_items
70
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyLocalsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.function import ( FunctionComplexityVisitor, ) function_with_locals = """ def function(): local_variable1 = 1 local_variable2 = 2 _ = None # `...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_function/test_local_variables.py
test_locals_correct_count
122
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.refactoring import ( UselessFinallyViolation, ) from wemake_python_styleguide.visitors.ast.exceptions import ( WrongTryExceptVisitor, ) right_try_example = """ try: ... except: ... """ wrong_try_example1 = """ try: ... finally: ... """ w...
[])
assert_*
collection
tests/test_visitors/test_ast/test_exceptions/test_try_finally.py
test_correct_finally
109
null
wemake-services/wemake-python-styleguide
from wemake_python_styleguide.options.config import Configuration FORMATTING_OPTIONS = frozenset(('--show-violation-links',)) def test_all_violations_have_versionadded(all_violations): """Ensures that all violations have `versionadded` tag.""" for violation in all_violations: assert '.. versionadded:...
violation.__doc__
assert
complex_expr
tests/test_violations/test_docs.py
test_all_violations_have_versionadded
9
null
wemake-services/wemake-python-styleguide
import re import subprocess import types from collections import Counter from typing import Final import pytest from wemake_python_styleguide.compat.constants import PY313 ERROR_PATTERN = re.compile(r'(WPS\d{3})') IGNORED_VIOLATIONS = ( 'WPS201', # it is a module level violation 'WPS202', # since our test...
errors.get(found_error)
assert
func_call
tests/test_checker/test_noqa.py
_assert_errors_count_in_output
333
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyImportedModuleMembersViolation, TooManyImportedNamesViolation, TooManyImportsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.imports import ( ImportMembersVisitor, ) module_import = '' module_with_regu...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_counts/test_imports_counts.py
test_module_import_counts_normal
55
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.compat.constants import PY311 from wemake_python_styleguide.violations.complexity import ( TooLongTryBodyViolation, ) from wemake_python_styleguide.visitors.ast.complexity.counts import ( TryExceptVisitor, ) try_without_except = """ try: {0} finally: ... """...
'2')
assert_*
string_literal
tests/test_visitors/test_ast/test_complexity/test_counts/test_try_body_length.py
test_try_body_wrong_custom_options
158
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.compat.constants import PY311 from wemake_python_styleguide.violations.consistency import ( IterableUnpackingViolation, ) from wemake_python_styleguide.visitors.ast.iterables import ( IterableUnpackingVisitor, ) _skip_mark = pytest.mark.skipif( not PY311, re...
[])
assert_*
collection
tests/test_visitors/test_ast/test_iterables/test_unpacking.py
test_correct_iterable_unpacking_usage
63
null
wemake-services/wemake-python-styleguide
from wemake_python_styleguide.violations.naming import TooLongNameViolation from wemake_python_styleguide.visitors.ast.naming.validation import ( WrongNameVisitor, ) long_name = 'incredibly_long_name_that_should_not_pass_the_long_name_test' def test_long_foreign_name( assert_errors, parse_ast_tree, fo...
[])
assert_*
collection
tests/test_visitors/test_ast/test_naming/test_naming_rules/test_long.py
test_long_foreign_name
44
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( NonTrivialExceptViolation, ) from wemake_python_styleguide.visitors.ast.exceptions import ( WrongExceptHandlerVisitor, ) use_complex_expression = """ try: ... except ValueError or TypeError: ... """ use_name_expression = "...
[])
assert_*
collection
tests/test_visitors/test_ast/test_exceptions/test_except_block_expression.py
test_use_exception
96
null
wemake-services/wemake-python-styleguide
from wemake_python_styleguide.options import config def test_option_docs(): """Ensures that all options are documented.""" for option in config.Configuration._options: # noqa: SLF001 option_value = option.long_option_name[2:] option_name = f'``{option_value}``' assert option_name in
config.__doc__
assert
complex_expr
tests/test_options/test_option_rules.py
test_option_docs
9
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyAwaitsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.function import ( FunctionComplexityVisitor, ) function_without_awaits = 'def function(): ...' function_async_without_awaits = 'async def function(): ...' ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_function/test_awaits_count.py
test_awaits_correct_count
49
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyReturnsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.function import ( FunctionComplexityVisitor, ) function_without_returns = 'def function(): ...' function_with_returns = """ def function(): if 1 > 2:...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_function/test_returns.py
test_returns_correct_count
59
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyBaseClassesViolation, ) from wemake_python_styleguide.visitors.ast.complexity.classes import ( ClassComplexityVisitor, ) correct_count = """ class CorrectClassName( FirstParentClass, SecondParentClass, ThirdParentCla...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_classes/test_bases_classes_counts.py
test_correct_count
61
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( GetterWithoutReturnViolation, ) from wemake_python_styleguide.visitors.ast.functions import ( FunctionSignatureVisitor, ) getter_function_with_implicit_return = """ def get_foo(): print('Hello world!') """ getter_function_with...
[])
assert_*
collection
tests/test_visitors/test_ast/test_functions/test_getter_without_return.py
test_correct_getters
247
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.visitors.ast.complexity.classes import ( MethodMembersVisitor, TooManyMethodsViolation, ) module_without_methods = """ def first(): ... def second(): ... """ module_with_async_functions = """ async def first(): ... async def second(): ... """ module_async_and_us...
option_values.max_methods)
assert_*
complex_expr
tests/test_visitors/test_ast/test_complexity/test_classes/test_method_counts.py
test_method_counts_violation
164
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.compat.constants import PY311 from wemake_python_styleguide.violations.complexity import ( TooManyExceptCasesViolation, ) from wemake_python_styleguide.visitors.ast.complexity.counts import ( TryExceptVisitor, ) try_without_except = """ try: ... finally: ......
'4')
assert_*
string_literal
tests/test_visitors/test_ast/test_complexity/test_counts/test_try_except.py
test_try_except_count_default
101
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.oop import ( UnpythonicGetterSetterViolation, ) from wemake_python_styleguide.visitors.ast.classes.classdef import ( WrongClassBodyVisitor, ) module_getter_and_setter = """ attribute = 1 def get_attribute(): ... def set_attribute(): ... """ sta...
[])
assert_*
collection
tests/test_visitors/test_ast/test_classes/test_getter_setter.py
test_valid_getter_and_setter
207
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( NotInWithUnaryOpViolation, ) from wemake_python_styleguide.visitors.ast.compares import ( NotInUnaryVisitor, ) @pytest.mark.parametrize( 'code', [ 'if x not in items: ...', 'result = x not in data', 'if...
[])
assert_*
collection
tests/test_visitors/test_ast/test_compares/test_not_in_unary.py
test_not_in_unary_ok
61
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyConditionsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.counts import ( ConditionsVisitor, ) empty_module = '' assignment = 'some = x > y or None' condition_with_single_if = """ if 4 > 2 and 3 / 2 == 1.5: ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_counts/test_condition_counts.py
test_module_condition_counts_normal
106
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( MutableModuleConstantViolation, ) from wemake_python_styleguide.visitors.ast.modules import ModuleConstantsVisitor module_constant = 'CONST = {0}' module_typed_constant = 'CONST: int = {0}' module_variable = 'some_variable = {0}' modu...
[])
assert_*
collection
tests/test_visitors/test_ast/test_modules/test_mutable_constants.py
test_correct_non_constant
83
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.naming import ( UnusedVariableIsUsedViolation, ) from wemake_python_styleguide.visitors.ast.functions import ( FunctionDefinitionVisitor, ) correct_module = """ _PROTECTED = 1 PUBLIC = _PROTECTED + 1 """ correct_class = """ class Test: _constant = 1 ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_functions/test_unused_variables.py
test_correct_variables
143
null
wemake-services/wemake-python-styleguide
import re import subprocess import types from collections import Counter from typing import Final import pytest from wemake_python_styleguide.compat.constants import PY313 ERROR_PATTERN = re.compile(r'(WPS\d{3})') IGNORED_VIOLATIONS = ( 'WPS201', # it is a module level violation 'WPS202', # since our test...
len(all_violations)
assert
func_call
tests/test_checker/test_noqa.py
test_codes
342
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.compat.constants import PY312 from wemake_python_styleguide.violations.complexity import ( TooManyTypeParamsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.counts import ( TypeParamsVisitor, ) type_alias_params6 = 'type Alias[A, B, C, D, E, F] = ....
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_counts/test_type_params312.py
test_type_params_correct_count
72
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( InfiniteWhileLoopViolation, ) from wemake_python_styleguide.visitors.ast.loops import WrongLoopVisitor template_simple = """ while True: {0} """ template_nested_while1 = """ while True: while other: {0} {0} """ te...
[])
assert_*
collection
tests/test_visitors/test_ast/test_loops/test_loops/test_infinite_while_loops.py
test_correct_while_loops_with_statements
210
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyAssertsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.function import ( FunctionComplexityVisitor, ) function_without_asserts = 'def function(): ...' function_with_asserts = """ def function(): if some: ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_function/test_asserts_count.py
test_asserts_correct_count
48
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyExpressionsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.function import ( FunctionComplexityVisitor, ) function_without_expressions = """ def function(): return 1 """ function_with_expressions = """ de...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_function/test_expressions.py
test_expressions_correct_count
51
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.refactoring import ( FalsyConstantCompareViolation, ) from wemake_python_styleguide.visitors.ast.compares import ( WrongConstantCompareVisitor, ) wrong_comparators = [ ('some', '[]'), ('some', '{}'), ('some', '()'), ('[]', 'some'), ('{...
proposed
assert
variable
tests/test_visitors/test_ast/test_compares/test_constant_compares/test_falsy_constant.py
_get_error_state
24
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.compat.constants import PY311 from wemake_python_styleguide.violations.best_practices import ( IncorrectExceptOrderViolation, ) from wemake_python_styleguide.visitors.ast.exceptions import ( WrongTryExceptVisitor, ) exception_template = """ try: ... except {0}: ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_exceptions/test_exception_order.py
test_correct_order_exception
88
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( ProblematicFunctionParamsViolation, ) from wemake_python_styleguide.visitors.ast.functions import ( FunctionSignatureVisitor, ) problematic_function1 = """ def function(arg1, arg2=2, arg3=3, /): ... """ problematic_function2 =...
[])
assert_*
collection
tests/test_visitors/test_ast/test_functions/test_problematic_params.py
test_correct_function_params
114
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( RaiseSystemExitViolation, ) from wemake_python_styleguide.visitors.ast.keywords import WrongRaiseVisitor template = 'raise {0}' @pytest.mark.parametrize( 'code', [ 'NotImplementedError', 'NotImplementedError()', ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_keywords/test_raise/test_system_error_violation.py
test_raise_good_errors
59
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( ExplicitStringConcatViolation, ) from wemake_python_styleguide.visitors.ast.operators import ( WrongMathOperatorVisitor, ) usage_template = 'constant {0}' docstring = """ def function(): '''Docstring''' variable = 'a' for...
[])
assert_*
collection
tests/test_visitors/test_ast/test_operators/test_string_concat.py
test_correct_operation
102
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( ControlVarUsedAfterBlockViolation, ) from wemake_python_styleguide.visitors.ast.blocks import ( AfterBlockVariablesVisitor, ) correct_for_loop1 = """ def wrapper(): for i, j in (): print(i, j) """ correct_for_loop2 = "...
[])
assert_*
collection
tests/test_visitors/test_ast/test_blocks/test_control_variables.py
test_control_variable_used_correctly
294
null
wemake-services/wemake-python-styleguide
from contextlib import suppress import pytest from wemake_python_styleguide.constants import SPECIAL_ARGUMENT_NAMES_WHITELIST from wemake_python_styleguide.violations.naming import ( ReservedArgumentNameViolation, TrailingUnderscoreViolation, ) from wemake_python_styleguide.visitors.ast.naming.validation impo...
argument)
assert_*
variable
tests/test_visitors/test_ast/test_naming/test_naming_rules/test_reserved_argument.py
test_reserved_argument_name
52
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( ZeroDivisionViolation, ) from wemake_python_styleguide.visitors.ast.operators import ( UselessOperatorsVisitor, ) usage_template = 'constant {0}' @pytest.mark.parametrize( 'expression', [ # Div, but not with zero: ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_operators/test_zero_div.py
test_correct_zero_div
147
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import WalrusViolation from wemake_python_styleguide.visitors.ast.operators import WalrusVisitor correct_assignment = 'x = 1' correct_if_condition = """ some = call() if some: ... """ correct_walrus_while_condition = """ while some := call(): ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_operators/test_walrus.py
test_not_walrus
79
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooLongCompareViolation, ) from wemake_python_styleguide.visitors.ast.complexity.counts import ( ConditionsVisitor, ) empty_module = '' one_compare = 'x > 1' two_compare = 'x < y() >= 2' one_equals = 'x == 1' two_equals = 'x == call()...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_counts/test_compare_complexity.py
test_module_compare_counts_normal
63
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.oop import YieldMagicMethodViolation from wemake_python_styleguide.visitors.ast.classes.methods import ( WrongMethodVisitor, ) method_template = """ class Test: def {0}(self, *args, **kwargs): {1} """ classmethod_template = """ class Test: @c...
method)
assert_*
variable
tests/test_visitors/test_ast/test_classes/test_methods/test_yield_magic_method.py
test_magic_generator
65
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import TooManyElifsViolation from wemake_python_styleguide.visitors.ast.complexity.counts import ElifVisitor module_with_one_elif = """ if 1 > 2: ... elif 2 > 3: ... else: ... """ module_with_two_elifs = """ if 1 > 2: ... elif 2 > 3: ...
'4')
assert_*
string_literal
tests/test_visitors/test_ast/test_complexity/test_counts/test_elifs.py
test_elif_incorrect_count
217
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyDecoratorsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.counts import ( ModuleMembersVisitor, ) function_with_decorators = """ @first @second(param=4) @third() def function(): ... """ class_with_decorators ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_counts/test_decorators_count.py
test_decorators_normal
63
null
wemake-services/wemake-python-styleguide
import io import tokenize import hypothesmith import pytest from hypothesis import HealthCheck, given, reject, settings from wemake_python_styleguide.checker import Checker settings.register_profile( 'slow', deadline=None, suppress_health_check=list(HealthCheck), ) settings.load_profile('slow') def _fix...
violation[2]
assert
complex_expr
tests/test_checker/test_hypothesis.py
test_no_exceptions
78
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( InconsistentYieldViolation, ) from wemake_python_styleguide.visitors.ast.keywords import ( ConsistentReturningVisitor, ) correct_example1 = """ def function(): yield """ correct_example2 = """ def function(): yield yield ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_keywords/test_consistency_returning/test_consistency_yield.py
test_correct_yield_statements
148
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.naming import ( TrailingUnderscoreViolation, ) from wemake_python_styleguide.visitors.ast.naming.validation import ( WrongNameVisitor, ) wrong_name = 'my_variable_' def test_foreign_trailing_underscore( assert_errors, parse_ast_tree, foreign_...
[])
assert_*
collection
tests/test_visitors/test_ast/test_naming/test_naming_rules/test_trailing_underscore.py
test_foreign_trailing_underscore
48
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.refactoring import ( ImplicitPrimitiveViolation, ) from wemake_python_styleguide.visitors.ast.functions import ( UselessLambdaDefinitionVisitor, ) @pytest.mark.parametrize( 'code', [ 'lambda x: 0', 'lambda *x: []', 'lambda ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_functions/test_implicit_primitive.py
test_correct_lambda
42
null
wemake-services/wemake-python-styleguide
import ast import pytest from wemake_python_styleguide.checker import Checker from wemake_python_styleguide.violations import naming @pytest.mark.parametrize( ('filename', 'error'), [ ('__magic__.py', naming.WrongModuleMagicNameViolation), ('util.py', naming.WrongModuleNameViolation), ...
error.code
assert
complex_expr
tests/test_checker/test_module_names.py
test_module_names
32
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( GettingElementByUnpackingViolation, SingleElementDestructuringViolation, WrongUnpackingViolation, ) from wemake_python_styleguide.violations.consistency import ( UnpackingIterableToListViolation, ) from wemake_python_stylegu...
[])
assert_*
collection
tests/test_visitors/test_ast/test_builtins/test_assign/test_unpacking_rules.py
test_correct_unpacking
139
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.cli.commands.explain import ( violation_loader, ) from wemake_python_styleguide.violations.best_practices import ( InitModuleHasLogicViolation, ) from wemake_python_styleguide.violations.naming import ( UpperCaseAttributeViolation, ) from wemake_python_styleguide...
None
assert
none_literal
tests/test_cli/test_explain_internals.py
test_violation_getter
29
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.naming import ( UnderscoredNumberNameViolation, ) from wemake_python_styleguide.visitors.ast.naming.validation import ( WrongNameVisitor, ) patterns = ( 'number_5', 'between_45_letters', 'with_multiple_groups_4_5', ) @pytest.mark.parametrize(...
[])
assert_*
collection
tests/test_visitors/test_ast/test_naming/test_naming_rules/test_underscored_number.py
test_number_prefix_foreign_name
56
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( StopIterationInsideGeneratorViolation, ) from wemake_python_styleguide.visitors.ast.functions import ( FunctionDefinitionVisitor, ) stop_iteration_method = """ class CheckStopIteration(): def check_stop_iteration(self): ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_functions/test_stop_iteration.py
test_stop_iteration_inside_bare_functions
138
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( OverusedExpressionViolation, ) from wemake_python_styleguide.visitors.ast.complexity.overuses import ( ExpressionOveruseVisitor, ) module_context = """ {0} {1} """ function_context1 = """ def function(): {0} {1} """ function_...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_overuses/test_overused_expressions.py
test_class_expression_use
257
null
wemake-services/wemake-python-styleguide
from wemake_python_styleguide.options import config def test_option_help(): """Ensures that all options has help.""" for option in config.Configuration._options: # noqa: SLF001 assert len(option.help) > 10 assert '%(default)s' in
option.help
assert
complex_expr
tests/test_options/test_option_rules.py
test_option_help
16
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( ContextManagerVariableDefinitionViolation, ) from wemake_python_styleguide.visitors.ast.keywords import ( WrongContextManagerVisitor, ) context_manager_definition = """ def wrapper(): with open('') as {0}: ... """ @pyt...
[])
assert_*
collection
tests/test_visitors/test_ast/test_keywords/test_context_managers/test_context_managers_definitions.py
test_context_manager_correct_definitions
65
null
wemake-services/wemake-python-styleguide
import string import pytest from wemake_python_styleguide.violations.best_practices import ( StringConstantRedefinedViolation, ) from wemake_python_styleguide.visitors.ast.builtins import WrongStringVisitor @pytest.mark.parametrize( 'code', [ # We don't test all values here, because of strange pa...
code)
assert_*
variable
tests/test_visitors/test_ast/test_builtins/test_strings/test_alphabet_string.py
test_alphabet_as_string_violation
48
null
wemake-services/wemake-python-styleguide
from collections import Counter import pytest from wemake_python_styleguide.compat.constants import PY311 def test_all_violations_correct_numbers(all_module_violations): """Ensures that all violations has correct violation code numbers.""" assert len(all_module_violations) == 7 for index, module in enum...
violation_class.code
assert
complex_expr
tests/test_violations/test_codes.py
test_all_violations_correct_numbers
37
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( MultipleIfsInComprehensionViolation, ) from wemake_python_styleguide.visitors.ast.loops import ( WrongComprehensionVisitor, ) list_ifs_multiple = """ def container(): nodes = [xy for xy in "abc" if xy != "a" if xy != "b" if xy != ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_loops/test_comprehensions/test_ifs_count.py
test_if_keyword_in_comprehension
125
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.refactoring import ( NegatedConditionsViolation, UselessTernaryViolation, ) from wemake_python_styleguide.visitors.ast.conditions import IfStatementVisitor template = '{0} if {1} else {2}' @pytest.mark.parametrize( ('left', 'compare', 'right'), [...
[])
assert_*
collection
tests/test_visitors/test_ast/test_conditions/test_useless_ternary.py
test_useful_ternary
40
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.oop import ( ShadowedClassAttributeViolation, ) from wemake_python_styleguide.visitors.ast.classes.attributes import ( ClassAttributeVisitor, ) class_attribute = """ class ClassWithAttrs: {0} = 0 def __init__(self) -> None: self.{1} = 2 "...
[])
assert_*
collection
tests/test_visitors/test_ast/test_classes/test_class_attributes/test_shadow_attributes.py
test_correct_fields
226
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( RaiseFromItselfViolation, ) from wemake_python_styleguide.visitors.ast.keywords import WrongRaiseVisitor raise_from_itself_outside_try = """ e = Exception('Some Exception') raise e from e """ raise_from_itself_inside_try = """ def rai...
[])
assert_*
collection
tests/test_visitors/test_ast/test_keywords/test_raise/test_raise_from_itself_violation.py
test_raise_from_other_exception
89
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.complexity import ( TooManyConditionsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.counts import ( ConditionsVisitor, ) empty_module = '' assignment = 'some = x > y or None' condition_with_single_if = """ if 4 > 2 and 3 / 2 == 1.5: ...
'5')
assert_*
string_literal
tests/test_visitors/test_ast/test_complexity/test_counts/test_condition_counts.py
test_module_condition_real_config
133
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( ApproximateConstantViolation, ) from wemake_python_styleguide.visitors.ast.builtins import ( WrongNumberVisitor, ) @pytest.mark.parametrize( 'variable_value', [ # We use string, because these values in numbers raise...
str(variable_value))
assert_*
func_call
tests/test_visitors/test_ast/test_builtins/test_numbers/test_approximate_constants.py
test_violation_on_approximate_constants
43
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.oop import YieldMagicMethodViolation from wemake_python_styleguide.visitors.ast.classes.methods import ( WrongMethodVisitor, ) method_template = """ class Test: def {0}(self, *args, **kwargs): {1} """ classmethod_template = """ class Test: @c...
[])
assert_*
collection
tests/test_visitors/test_ast/test_classes/test_methods/test_yield_magic_method.py
test_magic_statement
108
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.constants import MAGIC_METHODS_BLACKLIST from wemake_python_styleguide.violations.oop import BadMagicMethodViolation from wemake_python_styleguide.visitors.ast.classes.methods import ( WrongMethodVisitor, ) magic_method = """ class Example: def {0}(self): ... """ r...
method)
assert_*
variable
tests/test_visitors/test_ast/test_classes/test_methods/test_magic_methods.py
test_wrong_magic_used
32
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( ImportCollisionViolation, ) from wemake_python_styleguide.violations.consistency import ( DottedRawImportViolation, LocalFolderImportViolation, ) from wemake_python_styleguide.visitors.ast.imports import WrongImportVisitor corr...
[])
assert_*
collection
tests/test_visitors/test_ast/test_imports/test_imports_collision.py
test_correct_imports
118
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.refactoring import ( DuplicateCasePatternViolation, ) from wemake_python_styleguide.visitors.ast.conditions import MatchVisitor match_single = """ match some_value: case {0}: ... """ match_after_match = """ match some_value: case {0}: ...
code)
assert_*
variable
tests/test_visitors/test_ast/test_conditions/test_duplicated_case_patterns.py
test_same_conditions
150
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( LoopVariableDefinitionViolation, ) from wemake_python_styleguide.visitors.ast.loops import ( WrongLoopDefinitionVisitor, ) for_loop_def = """ def wrapper(): for {0} in some: ... """ @pytest.mark.parametrize( 'defin...
[])
assert_*
collection
tests/test_visitors/test_ast/test_loops/test_loops/test_variable_definitions_loops.py
test_correct_definition_loop
64
null
wemake-services/wemake-python-styleguide
from wemake_python_styleguide.violations.complexity import ( TooManyArgumentsViolation, ) from wemake_python_styleguide.visitors.ast.complexity.function import ( FunctionComplexityVisitor, ) def test_correct_arguments_count( assert_errors, parse_ast_tree, single_argument, default_options, m...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_function/test_arguments.py
test_correct_arguments_count
22
null
wemake-services/wemake-python-styleguide
from textwrap import indent import pytest from wemake_python_styleguide.violations.naming import ( UnusedVariableIsDefinedViolation, ) from wemake_python_styleguide.visitors.ast.naming.variables import ( UnusedVariableDefinitionVisitor, ) module_context = '{0}' function_context = """ def function(): {0} """...
[])
assert_*
collection
tests/test_visitors/test_ast/test_naming/test_unused/test_unused_definition.py
test_used_variable_tuple_definition_allowed
108
null
wemake-services/wemake-python-styleguide
import ast from contextlib import suppress from wemake_python_styleguide.checker import Checker from wemake_python_styleguide.violations.system import InternalErrorViolation from wemake_python_styleguide.visitors.base import BaseNodeVisitor def test_exception_handling( default_options, capsys, ): """Ensur...
captured.out
assert
complex_expr
tests/test_checker/test_exception_handling.py
test_exception_handling
28
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.compat.constants import PY311 from wemake_python_styleguide.visitors.ast.complexity.offset import ( OffsetVisitor, TooDeepNestingViolation, ) nested_if = """ def container(): if True: ... # this needs to be an ellipsis for the test """ nested_if2 = """...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_offset_visitor.py
test_nested_offset
140
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( WrongEmptyLinesCountViolation, ) from wemake_python_styleguide.visitors.tokenize.functions import ( WrongEmptyLinesCountVisitor, ) class_with_wrong_method = """ class WrongClass: def wrong_method(self): foo() ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_classes/test_wrong_empty_lines_count.py
test_success
303
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.naming import ( WrongUnusedVariableNameViolation, ) from wemake_python_styleguide.visitors.ast.naming.validation import ( WrongNameVisitor, ) @pytest.mark.parametrize( 'wrong_name', [ '_', ], ) def test_correct_unused_variable_name( ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_naming/test_naming_rules/test_wrong_unused_name.py
test_correct_unused_variable_name
59
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.compat.constants import PY311 from wemake_python_styleguide.violations.complexity import ( TooLongFinallyBodyViolation, ) from wemake_python_styleguide.visitors.ast.complexity.counts import ( TryExceptVisitor, ) try_finally_without_except = """ try: ... finally:...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_counts/test_finally_body_length.py
test_finally_body_count_custom_options
170
null
wemake-services/wemake-python-styleguide
import subprocess def test_invalid_options(absolute_path): """End-to-End test to check option validation works.""" process = subprocess.Popen( [ 'flake8', '--isolated', '--select', 'WPS', '--max-imports', '-5', # should be positiv...
stderr
assert
variable
tests/test_checker/test_invalid_options.py
test_invalid_options
24
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( NestedFunctionViolation, ) from wemake_python_styleguide.visitors.ast.complexity.nested import ( NESTED_FUNCTIONS_WHITELIST, NestedComplexityVisitor, ) nested_function_in_function = """ def container(): def {0}(): ... """ ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_complexity/test_nested/test_nested_functions.py
test_whitelist_nested_functions
228
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.constants import FUNCTIONS_BLACKLIST from wemake_python_styleguide.violations.best_practices import ( WrongFunctionCallViolation, ) from wemake_python_styleguide.visitors.ast.functions import ( WrongFunctionCallVisitor, ) regular_call = '{0}(*args, **kwargs)' assign...
[])
assert_*
collection
tests/test_visitors/test_ast/test_functions/test_wrong_function_calls.py
test_regular_function_called
112
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.refactoring import TypeCompareViolation from wemake_python_styleguide.visitors.ast.functions import ( WrongFunctionCallContextVisitor, ) simple_compare = '{0} == other' is_compare = '{0} is other' nested_compare = '{0} == int and other()' triple_compare = '{0...
[])
assert_*
collection
tests/test_visitors/test_ast/test_functions/test_call_context/test_type_compare.py
test_type_regular_usage
71
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.consistency import ( UselessContinueViolation, ) from wemake_python_styleguide.visitors.ast.loops import WrongLoopVisitor correct_for_loop = """ def wrapper(): for number in [123]: if number < 0: continue print(number) """ cor...
[])
assert_*
collection
tests/test_visitors/test_ast/test_loops/test_loops/test_useless_conitue.py
test_correct_continue_usage
89
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.refactoring import ( NegatedConditionsViolation, ) from wemake_python_styleguide.visitors.ast.conditions import IfStatementVisitor if_expression = '1 if {0} else 2' simple_conditions = """ if {0}: ... """ complex_elif_conditions = """ if {0}: ... eli...
[])
assert_*
collection
tests/test_visitors/test_ast/test_conditions/test_negated_conditions.py
test_negated_simple_conditions
75
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( ApproximateConstantViolation, ) from wemake_python_styleguide.visitors.ast.builtins import ( WrongNumberVisitor, ) @pytest.mark.parametrize( 'variable_value', [ 3.0, 3.1, 3.13, 3.142, # noqa...
[])
assert_*
collection
tests/test_visitors/test_ast/test_builtins/test_numbers/test_approximate_constants.py
test_no_violations_on_right_constants
93
null
wemake-services/wemake-python-styleguide
import re import subprocess import types from collections import Counter from typing import Final import pytest from wemake_python_styleguide.compat.constants import PY313 ERROR_PATTERN = re.compile(r'(WPS\d{3})') IGNORED_VIOLATIONS = ( 'WPS201', # it is a module level violation 'WPS202', # since our test...
0
assert
numeric_literal
tests/test_checker/test_noqa.py
test_noqa_fixture_without_ignore
457
null
wemake-services/wemake-python-styleguide
import pytest from wemake_python_styleguide.violations.best_practices import ( ComplexDefaultValueViolation, ) from wemake_python_styleguide.visitors.ast.functions import ( FunctionSignatureVisitor, ) function_with_defaults = """ def function(arg, with_default={0}): ... """ function_with_posonly_defaults...
[])
assert_*
collection
tests/test_visitors/test_ast/test_functions/test_complex_default_values.py
test_correct_function_defaults
140
null
wemake-services/wemake-python-styleguide
from typing import NamedTuple import pytest from wemake_python_styleguide.violations import oop from wemake_python_styleguide.visitors.ast.classes.methods import ( WrongMethodVisitor, ) regular_method_detailed = """ class Useless: {decorator} def function(self, {args_definition}): {statements} ...
[])
assert_*
collection
tests/test_visitors/test_ast/test_classes/test_methods/test_useless_overwriting_method.py
test_useful_due_to_invalid_decorator
217
null
reata/sqllineage
import pytest from ...helpers import assert_table_lineage_equal @pytest.mark.parametrize( "dialect", ["athena", "bigquery", "databricks", "hive", "mysql", "sparksql"] ) def test_select_with_schema_in_backtick(dialect: str): assert_table_lineage_equal(
{"schema1.tab1"})
assert_*
collection
tests/sql/table/test_select_dialect_specific.py
test_select_with_schema_in_backtick
21
null
reata/sqllineage
import pytest from ...helpers import assert_table_lineage_equal @pytest.mark.parametrize( "dialect", ["db2", "duckdb", "greenplum", "materialize", "oracle", "postgres", "snowflake"], ) def test_select_from_lateral_subqueries(dialect: str): """ db2: https://www.ibm.com/docs/en/informix-servers/12.10?to...
{"foo", "bar"})
assert_*
collection
tests/sql/table/test_select_dialect_specific.py
test_select_from_lateral_subqueries
116
null
reata/sqllineage
import os import tempfile from sqllineage.cli import main from sqllineage.config import SQLLineageConfig from sqllineage.core.models import SubQuery from sqllineage.runner import LineageRunner from sqllineage.utils.constant import LineageLevel from ..helpers import _gen_graph_operators, assert_table_lineage_equal de...
{"my_table"})
assert_*
collection
tests/core/test_runner.py
test_respect_sqlfluff_configuration_file
56
null
reata/sqllineage
from sqllineage.utils.entities import ColumnQualifierTuple from ...helpers import assert_column_lineage_equal def test_non_reserved_keyword_as_column_name(): sql = """INSERT INTO tab1 SELECT host FROM tab2 a""" asse
[ ( ColumnQualifierTuple("host", "tab2"), ColumnQualifierTuple("host", "tab1"), ) ])
assert_*
collection
tests/sql/column/test_column_select_column.py
test_non_reserved_keyword_as_column_name
223
null