Skip to content

Commit dbb1252

Browse files
[pre-commit] Upgrade to black 23.1a1 with 2023's formatting (#7965)
1 parent cf5ea8a commit dbb1252

34 files changed

+10
-44
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ repos:
4444
- id: isort
4545
exclude: doc/data/messages/(r/reimported|w/wrong-import-order|u/ungrouped-imports|m/misplaced-future|m/multiple-imports)/bad.py
4646
- repo: https://github.com/psf/black
47-
rev: 22.12.0
47+
rev: 23.1a1
4848
hooks:
4949
- id: black
5050
args: [--safe, --quiet]

examples/custom_raw.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def process_module(self, node: nodes.Module) -> None:
3232
the module's content is accessible via node.stream() function
3333
"""
3434
with node.stream() as stream:
35-
for (lineno, line) in enumerate(stream):
35+
for lineno, line in enumerate(stream):
3636
if line.rstrip().endswith("\\"):
3737
self.add_message("backslash-line-continuation", line=lineno)
3838

pylint/checkers/base/basic_error_checker.py

-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ def visit_functiondef(self, node: nodes.FunctionDef) -> None:
301301
visit_asyncfunctiondef = visit_functiondef
302302

303303
def _check_name_used_prior_global(self, node: nodes.FunctionDef) -> None:
304-
305304
scope_globals = {
306305
name: child
307306
for child in node.nodes_of_class(nodes.Global)

pylint/checkers/base_checker.py

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
@functools.total_ordering
3636
class BaseChecker(_ArgumentsProvider):
37-
3837
# checker name (you may reuse an existing one)
3938
name: str = ""
4039
# ordered list of options to control the checker behaviour

pylint/checkers/classes/class_checker.py

-1
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,6 @@ def _check_unused_private_functions(self, node: nodes.ClassDef) -> None:
975975
"cls",
976976
node.name,
977977
}:
978-
979978
break
980979

981980
# Check type(self).__attrname

pylint/checkers/classes/special_methods_checker.py

-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ def _check_getnewargs_ex(
394394
(inferred.elts[0], self._is_tuple),
395395
(inferred.elts[1], self._is_dict),
396396
):
397-
398397
if isinstance(arg, nodes.Call):
399398
arg = safe_infer(arg)
400399

pylint/checkers/misc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def _get_by_id_managed_msgs(self) -> list[ManagedMessage]:
4242
def process_module(self, node: nodes.Module) -> None:
4343
"""Inspect the source file to find messages activated or deactivated by id."""
4444
managed_msgs = self._get_by_id_managed_msgs()
45-
for (mod_name, msgid, symbol, lineno, is_disabled) in managed_msgs:
45+
for mod_name, msgid, symbol, lineno, is_disabled in managed_msgs:
4646
if mod_name == node.name:
4747
verb = "disable" if is_disabled else "enable"
4848
txt = f"'{msgid}' is cryptic: use '# pylint: {verb}={symbol}' instead"

pylint/checkers/refactoring/recommendation_checker.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

1515
class RecommendationChecker(checkers.BaseChecker):
16-
1716
name = "refactoring"
1817
msgs = {
1918
"C0200": (

pylint/checkers/refactoring/refactoring_checker.py

-2
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,6 @@ def _type_and_name_are_equal(node_a: Any, node_b: Any) -> bool:
788788
return False
789789

790790
def _is_dict_get_block(self, node: nodes.If) -> bool:
791-
792791
# "if <compare node>"
793792
if not isinstance(node.test, nodes.Compare):
794793
return False
@@ -1115,7 +1114,6 @@ def _has_exit_in_scope(scope: nodes.LocalsDictNodeNG) -> bool:
11151114
)
11161115

11171116
def _check_quit_exit_call(self, node: nodes.Call) -> None:
1118-
11191117
if isinstance(node.func, nodes.Name) and node.func.name in BUILTIN_EXIT_FUNCS:
11201118
# If we have `exit` imported from `sys` in the current or global scope, exempt this instance.
11211119
local_scope = node.scope()

pylint/checkers/spelling.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
427427
return
428428

429429
# Process tokens and look for comments.
430-
for (tok_type, token, (start_row, _), _, _) in tokens:
430+
for tok_type, token, (start_row, _), _, _ in tokens:
431431
if tok_type == tokenize.COMMENT:
432432
if start_row == 1 and token.startswith("#!/"):
433433
# Skip shebang lines

pylint/checkers/threading_checker.py

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class ThreadingChecker(BaseChecker):
4444

4545
@only_required_for_messages("useless-with-lock")
4646
def visit_with(self, node: nodes.With) -> None:
47-
4847
context_managers = (c for c, _ in node.items if isinstance(c, nodes.Call))
4948
for context_manager in context_managers:
5049
if isinstance(context_manager, nodes.Call):

pylint/checkers/unicode.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def process_module(self, node: nodes.Module) -> None:
524524
stream.seek(0)
525525

526526
# Check for invalid content (controls/chars)
527-
for (lineno, line) in enumerate(
527+
for lineno, line in enumerate(
528528
_fix_utf16_32_line_stream(stream, codec), start=1
529529
):
530530
if lineno == 1:

pylint/checkers/variables.py

-3
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,6 @@ def _check_consumer(
17671767
and not utils.is_defined_before(node)
17681768
and not astroid.are_exclusive(stmt, defstmt, ("NameError",))
17691769
):
1770-
17711770
# Used and defined in the same place, e.g `x += 1` and `del x`
17721771
defined_by_stmt = defstmt is stmt and isinstance(
17731772
node, (nodes.DelName, nodes.AssignName)
@@ -1779,7 +1778,6 @@ def _check_consumer(
17791778
or isinstance(defstmt, nodes.Delete)
17801779
):
17811780
if not utils.node_ignores_exception(node, NameError):
1782-
17831781
# Handle postponed evaluation of annotations
17841782
if not (
17851783
self._postponed_evaluation_enabled
@@ -2074,7 +2072,6 @@ def _is_variable_violation(
20742072
and isinstance(frame, nodes.ClassDef)
20752073
and node.name in frame.locals
20762074
):
2077-
20782075
# This rule verifies that if the definition node of the
20792076
# checked name is an Arguments node and if the name
20802077
# is used a default value in the arguments defaults

pylint/epylint.py

-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ def lint(filename: str, options: Sequence[str] = ()) -> int:
107107
with Popen(
108108
cmd, stdout=PIPE, cwd=parent_path, env=_get_env(), universal_newlines=True
109109
) as process:
110-
111110
for line in process.stdout: # type: ignore[union-attr]
112111
# remove pylintrc warning
113112
if line.startswith("No config file found"):

pylint/extensions/bad_builtin.py

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424

2525
class BadBuiltinChecker(BaseChecker):
26-
2726
name = "deprecated_builtins"
2827
msgs = {
2928
"W0141": (

pylint/extensions/code_style.py

-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ def _check_consider_using_assignment_expr(self, node: nodes.If) -> None:
225225
if CodeStyleChecker._check_prev_sibling_to_if_stmt(
226226
prev_sibling, node_name.name
227227
):
228-
229228
# Check if match statement would be a better fit.
230229
# I.e. multiple ifs that test the same name.
231230
if CodeStyleChecker._check_ignore_assignment_expr_suggestion(

pylint/extensions/consider_ternary_expression.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818

1919
class ConsiderTernaryExpressionChecker(BaseChecker):
20-
2120
name = "consider_ternary_expression"
2221
msgs = {
2322
"W0160": (
@@ -41,7 +40,7 @@ def visit_if(self, node: nodes.If) -> None:
4140
if not isinstance(bst, nodes.Assign) or not isinstance(ost, nodes.Assign):
4241
return
4342

44-
for (bname, oname) in zip(bst.targets, ost.targets):
43+
for bname, oname in zip(bst.targets, ost.targets):
4544
if not isinstance(bname, nodes.AssignName) or not isinstance(
4645
oname, nodes.AssignName
4746
):

pylint/extensions/empty_comment.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def comment_part_of_string(line: bytes, comment_idx: int) -> bool:
4040

4141

4242
class CommentChecker(BaseRawFileChecker):
43-
4443
name = "empty-comment"
4544
msgs = {
4645
"R2044": (
@@ -55,7 +54,7 @@ class CommentChecker(BaseRawFileChecker):
5554

5655
def process_module(self, node: nodes.Module) -> None:
5756
with node.stream() as stream:
58-
for (line_num, line) in enumerate(stream):
57+
for line_num, line in enumerate(stream):
5958
line = line.rstrip()
6059
if line.endswith(b"#"):
6160
if not is_line_commented(line[:-1]):

pylint/extensions/eq_without_hash.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818

1919
class EqWithoutHash(checkers.BaseChecker):
20-
2120
name = "eq-without-hash"
2221

2322
msgs = {

pylint/extensions/for_any_all.py

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424

2525
class ConsiderUsingAnyOrAllChecker(BaseChecker):
26-
2726
name = "consider-using-any-or-all"
2827
msgs = {
2928
"C0501": (

pylint/extensions/no_self_use.py

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424

2525
class NoSelfUseChecker(BaseChecker):
26-
2726
name = "no_self_use"
2827
msgs = {
2928
"R6301": (

pylint/extensions/private_import.py

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020

2121
class PrivateImportChecker(BaseChecker):
22-
2322
name = "import-private-name"
2423
msgs = {
2524
"C2701": (

pylint/extensions/redefined_loop_name.py

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616

1717
class RedefinedLoopNameChecker(checkers.BaseChecker):
18-
1918
name = "redefined-loop-name"
2019

2120
msgs = {

pylint/extensions/set_membership.py

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717

1818
class SetMembershipChecker(BaseChecker):
19-
2019
name = "set_membership"
2120
msgs = {
2221
"R6201": (

pylint/extensions/while_used.py

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919

2020
class WhileChecker(BaseChecker):
21-
2221
name = "while_used"
2322
msgs = {
2423
"W0149": (

pylint/lint/message_state_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
347347
prev_line = None
348348
saw_newline = True
349349
seen_newline = True
350-
for (tok_type, content, start, _, _) in tokens:
350+
for tok_type, content, start, _, _ in tokens:
351351
if prev_line and prev_line != start[0]:
352352
saw_newline = seen_newline
353353
seen_newline = False

pylint/pyreverse/diagrams.py

-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ def extract_relationships(self) -> None:
225225
for name, values in list(node.associations_type.items()) + list(
226226
node.locals_type.items()
227227
):
228-
229228
for value in values:
230229
self.assign_association_relationship(
231230
value, obj, name, "association"

requirements_test_pre_commit.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Everything in this file should reflect the pre-commit configuration
22
# in .pre-commit-config.yaml
33
bandit==1.7.4
4-
black==22.12.0
4+
black==23.1a1
55
flake8>=5.0.0
66
flake8-bugbear==22.12.6
77
flake8-typing-imports==1.14.0

tests/checkers/unittest_deprecated.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def deprecated_classes(self, module: str) -> list[str]:
2525

2626
def deprecated_arguments(
2727
self, method: str
28-
) -> (tuple[tuple[int | None, str], ...] | tuple[tuple[int, str], tuple[int, str]]):
28+
) -> tuple[tuple[int | None, str], ...] | tuple[tuple[int, str], tuple[int, str]]:
2929
if method == "myfunction1":
3030
# def myfunction1(arg1, deprecated_arg1='spam')
3131
return ((1, "deprecated_arg1"),)
@@ -485,7 +485,6 @@ def mymethod2(self, arg1, deprecated_arg1, arg2='foo', deprecated_arg2='spam'):
485485
self.checker.visit_call(node)
486486

487487
def test_class_deprecated_arguments(self) -> None:
488-
489488
node = astroid.extract_node(
490489
"""
491490
class MyClass:

tests/checkers/unittest_design.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010

1111
class TestDesignChecker(CheckerTestCase):
12-
1312
CHECKER_CLASS = design_analysis.MisdesignChecker
1413

1514
@set_config(

tests/checkers/unittest_imports.py

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919

2020
class TestImportsChecker(CheckerTestCase):
21-
2221
CHECKER_CLASS = imports.ImportsChecker
2322

2423
def test_relative_beyond_top_level(self) -> None:

tests/checkers/unittest_variables.py

-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919

2020
class TestVariablesChecker(CheckerTestCase):
21-
2221
CHECKER_CLASS = variables.VariablesChecker
2322

2423
def test_all_elements_without_parent(self) -> None:
@@ -31,7 +30,6 @@ def test_all_elements_without_parent(self) -> None:
3130

3231

3332
class TestVariablesCheckerWithTearDown(CheckerTestCase):
34-
3533
CHECKER_CLASS = variables.VariablesChecker
3634

3735
def setup_method(self) -> None:
@@ -209,7 +207,6 @@ class TestMissingSubmodule(CheckerTestCase):
209207

210208
@staticmethod
211209
def test_package_all() -> None:
212-
213210
sys.path.insert(0, REGR_DATA_DIR)
214211
try:
215212
linter.check([os.path.join(REGR_DATA_DIR, "package_all")])

tests/lint/unittest_lint.py

-2
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,6 @@ def test_pylintrc() -> None:
996996
@pytest.mark.usefixtures("pop_pylintrc")
997997
def test_pylintrc_parentdir() -> None:
998998
with tempdir() as chroot:
999-
1000999
create_files(
10011000
[
10021001
"a/pylintrc",
@@ -1134,7 +1133,6 @@ def test_by_module_statement_value(initialized_linter: PyLinter) -> None:
11341133

11351134
by_module_stats = linter.stats.by_module
11361135
for module, module_stats in by_module_stats.items():
1137-
11381136
linter2 = initialized_linter
11391137
if module == "data":
11401138
linter2.check([os.path.join(os.path.dirname(__file__), "data/__init__.py")])

tests/test_deprecation.py

-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def test_reporter_implements() -> None:
4747
"""Test that __implements__ on BaseReporter has been deprecated correctly."""
4848

4949
class MyReporter(BaseReporter):
50-
5150
__implements__ = IReporter
5251

5352
def _display(self, layout: Section) -> None:
@@ -61,7 +60,6 @@ def test_checker_implements() -> None:
6160
"""Test that __implements__ on BaseChecker has been deprecated correctly."""
6261

6362
class MyChecker(BaseChecker):
64-
6563
__implements__ = IAstroidChecker
6664

6765
with pytest.warns(DeprecationWarning):

0 commit comments

Comments
 (0)