Skip to content

Commit

Permalink
APply ruff with preview = true (#3156)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn authored Dec 13, 2024
1 parent a7b2e6f commit 6716807
Show file tree
Hide file tree
Showing 51 changed files with 138 additions and 115 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ repos:
- id: mixed-line-ending
args: [--fix=lf]
- id: check-case-conflict
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.4
hooks:
- id: check-dependabot
- id: check-github-workflows
- repo: https://github.com/rhysd/actionlint
rev: v1.7.3
hooks:
Expand Down
2 changes: 1 addition & 1 deletion scripts/check_generic_visit.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def main() -> NoReturn:
report('"self.generic_visit(node)" should be last statement here:')

for fn, line in matches:
with open(fn) as fp:
with open(fn, encoding='utf8') as fp:
lines = fp.read().splitlines()
report(
'\t{}:{}\n\t{}'.format(
Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/violations.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _load_all_violation_classes():
classes.update(
{
module: sorted(only_classes, key=attrgetter('code')),
}
},
)
return classes

Expand Down
4 changes: 2 additions & 2 deletions tests/test_checker/test_noqa.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
'WPS614': 1,
'WPS615': 2,
'WPS616': 1,
}
},
)

# Violations which may be tweaked by `i_control_code` option:
Expand All @@ -285,7 +285,7 @@
'WPS113': 0,
'WPS412': 0,
'WPS413': 0,
}
},
)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_violations/test_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_all_violations_are_final(all_violations):
def test_all_unique_violation_messages(all_violations):
"""Ensures that all violations have unique violation messages."""
messages = Counter(
[violation.error_template for violation in all_violations]
[violation.error_template for violation in all_violations],
)
for message, count in messages.items():
assert count == 1, message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_useless_overwriting(
super_args=super_args,
method_name='function',
args_invocation=method_args.invocation,
)
),
)
tree = parse_ast_tree(formatted_code)

Expand Down Expand Up @@ -199,7 +199,7 @@ def test_useful_due_to_invalid_decorator(
super_args=super_args,
method_name='function',
args_invocation=method_args.invocation,
)
),
)
tree = parse_ast_tree(formatted_code)

Expand Down Expand Up @@ -238,7 +238,7 @@ def test_useful_due_to_invalid_statements(
super_args=super_args,
method_name='function',
args_invocation=method_args.invocation,
)
),
)
tree = parse_ast_tree(formatted_code)

Expand Down Expand Up @@ -277,7 +277,7 @@ def test_useful_due_to_invalid_super_args(
super_args=super_args,
method_name='function',
args_invocation=method_args.invocation,
)
),
)
tree = parse_ast_tree(formatted_code)

Expand Down Expand Up @@ -316,7 +316,7 @@ def test_useful_due_to_invalid_method(
super_args=super_args,
method_name='invalid_function',
args_invocation=method_args.invocation,
)
),
)
tree = parse_ast_tree(formatted_code)

Expand Down Expand Up @@ -355,7 +355,7 @@ def test_useful_due_to_invalid_method_args(
super_args=super_args,
method_name='function',
args_invocation=method_args.invocation,
)
),
)
tree = parse_ast_tree(formatted_code)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_visitors/test_ast/test_compares/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
(
if_with_is,
if_with_is_not,
)
),
)

EQUAL_COMPARES = frozenset(
Expand All @@ -44,7 +44,7 @@
if_with_not_eq,
assert_construct,
assert_with_message,
)
),
)

OTHER_COMPARES = frozenset(
Expand All @@ -55,7 +55,7 @@
if_with_gte,
ternary,
while_construct,
)
),
)


Expand Down Expand Up @@ -87,7 +87,7 @@ def other_conditions(request):
params=[
if_with_in,
if_with_not_in,
]
],
)
def in_conditions(request):
"""Fixture that returns simple conditionals."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def method(arg1, arg2): ...
new_method_without_arguments,
metaclass_without_arguments,
staticmethod_with_no_argument,
]
],
)
def no_argument(request):
"""Fixture that returns different code examples that have no args."""
Expand All @@ -122,7 +122,7 @@ def no_argument(request):
new_method_single_argument,
metaclass_with_single_argument,
staticmethod_with_single_argument,
]
],
)
def single_argument(request):
"""Fixture that returns different code examples that have one arg."""
Expand All @@ -137,7 +137,7 @@ def single_argument(request):
function_with_posonly,
method_with_arguments,
staticmethod_with_arguments,
]
],
)
def two_arguments(request):
"""Fixture that returns different code examples that have two args."""
Expand Down
12 changes: 6 additions & 6 deletions tests/test_visitors/test_ast/test_naming/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def container():
match_as_explicit,
match_inner,
match_star,
)
),
)

if PY312:
Expand All @@ -270,7 +270,7 @@ def container():
(
foreign_attribute,
foreign_nested_attribute,
)
),
)

_ATTRIBUTES = (
Expand All @@ -283,7 +283,7 @@ def container():
static_typed_annotation,
instance_attribute,
instance_typed_attribute,
)
),
)
| _FOREIGN_NAMING_PATTERNS
)
Expand All @@ -292,7 +292,7 @@ def container():
(
# Not really an attribute, but similar:
type_param_class,
)
),
)


Expand All @@ -302,7 +302,7 @@ def container():
variable_def,
with_variable,
for_variable,
)
),
)

# Raw unused variables return True for logic.naming.access.is_unused().
Expand All @@ -320,7 +320,7 @@ def container():
assignment_expression,
# Pattern matching:
match_as_explicit,
)
),
)

_FORBIDDEN_RAW_UNUSED = _FORBIDDEN_BOTH_RAW_AND_PROTECTED_UNUSED | {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_unused_variable_tuple_definition(
forbidden_tuple_unused_template.format(bad_name),
' ' * indentation,
),
)
),
),
)

Expand Down Expand Up @@ -98,7 +98,7 @@ def test_used_variable_tuple_definition_allowed(
forbidden_tuple_unused_template.format(bad_name),
' ' * indentation,
),
)
),
),
)

Expand Down Expand Up @@ -143,7 +143,7 @@ def test_raw_unused_variable_definition(
forbidden_raw_unused_template.format(bad_name),
' ' * indentation,
),
)
),
),
)

Expand Down Expand Up @@ -186,7 +186,7 @@ def test_raw_unused_variable_definition_allowed(
allowed_raw_unused_template.format(bad_name),
' ' * indentation,
),
)
),
),
)

Expand Down Expand Up @@ -227,7 +227,7 @@ def test_protected_unused_variable_definition(
forbidden_protected_unused_template.format(bad_name),
' ' * indentation,
),
)
),
),
)

Expand Down Expand Up @@ -269,7 +269,7 @@ def test_protected_unused_var_definition_allowed(
allowed_protected_unused_template.format(bad_name),
' ' * indentation,
),
)
),
),
)

Expand Down Expand Up @@ -312,7 +312,7 @@ def test_used_variable_definition_allowed(
naming_template.format(bad_name),
' ' * indentation,
),
)
),
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
'^',
'>>',
'<<',
)
),
)


Expand Down
4 changes: 2 additions & 2 deletions tests/test_visitors/test_tokenize/test_primitives/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
default_param,
default_param_with_type,
statement_with_expression,
]
],
)
def primitives_usages(request):
"""Fixture to return possible cases of promitives use cases."""
Expand Down Expand Up @@ -58,7 +58,7 @@ def factory(template: str) -> str:
'regular_number_wrapper',
'negative_number_wrapper',
'positive_number_wrapper',
]
],
)
def number_sign(request):
"""Fixture that returns regular, negative, and positive numbers."""
Expand Down
2 changes: 1 addition & 1 deletion wemake_python_styleguide/compat/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
str: 'Str',
bytes: 'Bytes',
type(...): 'Ellipsis',
}
},
)


Expand Down
Loading

0 comments on commit 6716807

Please sign in to comment.