Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit] Trying out black 23.1a1 #7965

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ repos:
- id: isort
exclude: doc/data/messages/(r/reimported|w/wrong-import-order|u/ungrouped-imports|m/misplaced-future|m/multiple-imports)/bad.py
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1a1
hooks:
- id: black
args: [--safe, --quiet]
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def process_module(self, node: nodes.Module) -> None:
the module's content is accessible via node.stream() function
"""
with node.stream() as stream:
for (lineno, line) in enumerate(stream):
for lineno, line in enumerate(stream):
if line.rstrip().endswith("\\"):
self.add_message("backslash-line-continuation", line=lineno)

Expand Down
1 change: 0 additions & 1 deletion pylint/checkers/base/basic_error_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ def visit_functiondef(self, node: nodes.FunctionDef) -> None:
visit_asyncfunctiondef = visit_functiondef

def _check_name_used_prior_global(self, node: nodes.FunctionDef) -> None:

scope_globals = {
name: child
for child in node.nodes_of_class(nodes.Global)
Expand Down
1 change: 0 additions & 1 deletion pylint/checkers/base_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

@functools.total_ordering
class BaseChecker(_ArgumentsProvider):

# checker name (you may reuse an existing one)
name: str = ""
# ordered list of options to control the checker behaviour
Expand Down
1 change: 0 additions & 1 deletion pylint/checkers/classes/class_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,6 @@ def _check_unused_private_functions(self, node: nodes.ClassDef) -> None:
"cls",
node.name,
}:

break

# Check type(self).__attrname
Expand Down
1 change: 0 additions & 1 deletion pylint/checkers/classes/special_methods_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ def _check_getnewargs_ex(
(inferred.elts[0], self._is_tuple),
(inferred.elts[1], self._is_dict),
):

if isinstance(arg, nodes.Call):
arg = safe_infer(arg)

Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _get_by_id_managed_msgs(self) -> list[ManagedMessage]:
def process_module(self, node: nodes.Module) -> None:
"""Inspect the source file to find messages activated or deactivated by id."""
managed_msgs = self._get_by_id_managed_msgs()
for (mod_name, msgid, symbol, lineno, is_disabled) in managed_msgs:
for mod_name, msgid, symbol, lineno, is_disabled in managed_msgs:
if mod_name == node.name:
verb = "disable" if is_disabled else "enable"
txt = f"'{msgid}' is cryptic: use '# pylint: {verb}={symbol}' instead"
Expand Down
1 change: 0 additions & 1 deletion pylint/checkers/refactoring/recommendation_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class RecommendationChecker(checkers.BaseChecker):

name = "refactoring"
msgs = {
"C0200": (
Expand Down
2 changes: 0 additions & 2 deletions pylint/checkers/refactoring/refactoring_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,6 @@ def _type_and_name_are_equal(node_a: Any, node_b: Any) -> bool:
return False

def _is_dict_get_block(self, node: nodes.If) -> bool:

# "if <compare node>"
if not isinstance(node.test, nodes.Compare):
return False
Expand Down Expand Up @@ -1114,7 +1113,6 @@ def _has_exit_in_scope(scope: nodes.LocalsDictNodeNG) -> bool:
)

def _check_quit_exit_call(self, node: nodes.Call) -> None:

if isinstance(node.func, nodes.Name) and node.func.name in BUILTIN_EXIT_FUNCS:
# If we have `exit` imported from `sys` in the current or global scope, exempt this instance.
local_scope = node.scope()
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/spelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
return

# Process tokens and look for comments.
for (tok_type, token, (start_row, _), _, _) in tokens:
for tok_type, token, (start_row, _), _, _ in tokens:
if tok_type == tokenize.COMMENT:
if start_row == 1 and token.startswith("#!/"):
# Skip shebang lines
Expand Down
1 change: 0 additions & 1 deletion pylint/checkers/threading_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class ThreadingChecker(BaseChecker):

@only_required_for_messages("useless-with-lock")
def visit_with(self, node: nodes.With) -> None:

context_managers = (c for c, _ in node.items if isinstance(c, nodes.Call))
for context_manager in context_managers:
if isinstance(context_manager, nodes.Call):
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def process_module(self, node: nodes.Module) -> None:
stream.seek(0)

# Check for invalid content (controls/chars)
for (lineno, line) in enumerate(
for lineno, line in enumerate(
_fix_utf16_32_line_stream(stream, codec), start=1
):
if lineno == 1:
Expand Down
3 changes: 0 additions & 3 deletions pylint/checkers/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,6 @@ def _check_consumer(
and not utils.is_defined_before(node)
and not astroid.are_exclusive(stmt, defstmt, ("NameError",))
):

# Used and defined in the same place, e.g `x += 1` and `del x`
defined_by_stmt = defstmt is stmt and isinstance(
node, (nodes.DelName, nodes.AssignName)
Expand All @@ -1779,7 +1778,6 @@ def _check_consumer(
or isinstance(defstmt, nodes.Delete)
):
if not utils.node_ignores_exception(node, NameError):

# Handle postponed evaluation of annotations
if not (
self._postponed_evaluation_enabled
Expand Down Expand Up @@ -2074,7 +2072,6 @@ def _is_variable_violation(
and isinstance(frame, nodes.ClassDef)
and node.name in frame.locals
):

# This rule verifies that if the definition node of the
# checked name is an Arguments node and if the name
# is used a default value in the arguments defaults
Expand Down
1 change: 0 additions & 1 deletion pylint/epylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def lint(filename: str, options: Sequence[str] = ()) -> int:
with Popen(
cmd, stdout=PIPE, cwd=parent_path, env=_get_env(), universal_newlines=True
) as process:

for line in process.stdout: # type: ignore[union-attr]
# remove pylintrc warning
if line.startswith("No config file found"):
Expand Down
1 change: 0 additions & 1 deletion pylint/extensions/bad_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@


class BadBuiltinChecker(BaseChecker):

name = "deprecated_builtins"
msgs = {
"W0141": (
Expand Down
1 change: 0 additions & 1 deletion pylint/extensions/code_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ def _check_consider_using_assignment_expr(self, node: nodes.If) -> None:
if CodeStyleChecker._check_prev_sibling_to_if_stmt(
prev_sibling, node_name.name
):

# Check if match statement would be a better fit.
# I.e. multiple ifs that test the same name.
if CodeStyleChecker._check_ignore_assignment_expr_suggestion(
Expand Down
3 changes: 1 addition & 2 deletions pylint/extensions/consider_ternary_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


class ConsiderTernaryExpressionChecker(BaseChecker):

name = "consider_ternary_expression"
msgs = {
"W0160": (
Expand All @@ -41,7 +40,7 @@ def visit_if(self, node: nodes.If) -> None:
if not isinstance(bst, nodes.Assign) or not isinstance(ost, nodes.Assign):
return

for (bname, oname) in zip(bst.targets, ost.targets):
for bname, oname in zip(bst.targets, ost.targets):
if not isinstance(bname, nodes.AssignName) or not isinstance(
oname, nodes.AssignName
):
Expand Down
3 changes: 1 addition & 2 deletions pylint/extensions/empty_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def comment_part_of_string(line: bytes, comment_idx: int) -> bool:


class CommentChecker(BaseRawFileChecker):

name = "empty-comment"
msgs = {
"R2044": (
Expand All @@ -55,7 +54,7 @@ class CommentChecker(BaseRawFileChecker):

def process_module(self, node: nodes.Module) -> None:
with node.stream() as stream:
for (line_num, line) in enumerate(stream):
for line_num, line in enumerate(stream):
line = line.rstrip()
if line.endswith(b"#"):
if not is_line_commented(line[:-1]):
Expand Down
1 change: 0 additions & 1 deletion pylint/extensions/eq_without_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


class EqWithoutHash(checkers.BaseChecker):

name = "eq-without-hash"

msgs = {
Expand Down
1 change: 0 additions & 1 deletion pylint/extensions/for_any_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@


class ConsiderUsingAnyOrAllChecker(BaseChecker):

name = "consider-using-any-or-all"
msgs = {
"C0501": (
Expand Down
1 change: 0 additions & 1 deletion pylint/extensions/no_self_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@


class NoSelfUseChecker(BaseChecker):

name = "no_self_use"
msgs = {
"R6301": (
Expand Down
1 change: 0 additions & 1 deletion pylint/extensions/private_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


class PrivateImportChecker(BaseChecker):

name = "import-private-name"
msgs = {
"C2701": (
Expand Down
1 change: 0 additions & 1 deletion pylint/extensions/redefined_loop_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


class RedefinedLoopNameChecker(checkers.BaseChecker):

name = "redefined-loop-name"

msgs = {
Expand Down
1 change: 0 additions & 1 deletion pylint/extensions/set_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


class SetMembershipChecker(BaseChecker):

name = "set_membership"
msgs = {
"R6201": (
Expand Down
1 change: 0 additions & 1 deletion pylint/extensions/while_used.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


class WhileChecker(BaseChecker):

name = "while_used"
msgs = {
"W0149": (
Expand Down
2 changes: 1 addition & 1 deletion pylint/lint/message_state_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
prev_line = None
saw_newline = True
seen_newline = True
for (tok_type, content, start, _, _) in tokens:
for tok_type, content, start, _, _ in tokens:
if prev_line and prev_line != start[0]:
saw_newline = seen_newline
seen_newline = False
Expand Down
1 change: 0 additions & 1 deletion pylint/pyreverse/diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ def extract_relationships(self) -> None:
for name, values in list(node.associations_type.items()) + list(
node.locals_type.items()
):

for value in values:
self.assign_association_relationship(
value, obj, name, "association"
Expand Down
3 changes: 1 addition & 2 deletions tests/checkers/unittest_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def deprecated_classes(self, module: str) -> list[str]:

def deprecated_arguments(
self, method: str
) -> (tuple[tuple[int | None, str], ...] | tuple[tuple[int, str], tuple[int, str]]):
) -> tuple[tuple[int | None, str], ...] | tuple[tuple[int, str], tuple[int, str]]:
if method == "myfunction1":
# def myfunction1(arg1, deprecated_arg1='spam')
return ((1, "deprecated_arg1"),)
Expand Down Expand Up @@ -485,7 +485,6 @@ def mymethod2(self, arg1, deprecated_arg1, arg2='foo', deprecated_arg2='spam'):
self.checker.visit_call(node)

def test_class_deprecated_arguments(self) -> None:

node = astroid.extract_node(
"""
class MyClass:
Expand Down
1 change: 0 additions & 1 deletion tests/checkers/unittest_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


class TestDesignChecker(CheckerTestCase):

CHECKER_CLASS = design_analysis.MisdesignChecker

@set_config(
Expand Down
1 change: 0 additions & 1 deletion tests/checkers/unittest_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


class TestImportsChecker(CheckerTestCase):

CHECKER_CLASS = imports.ImportsChecker

def test_relative_beyond_top_level(self) -> None:
Expand Down
3 changes: 0 additions & 3 deletions tests/checkers/unittest_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


class TestVariablesChecker(CheckerTestCase):

CHECKER_CLASS = variables.VariablesChecker

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


class TestVariablesCheckerWithTearDown(CheckerTestCase):

CHECKER_CLASS = variables.VariablesChecker

def setup_method(self) -> None:
Expand Down Expand Up @@ -209,7 +207,6 @@ class TestMissingSubmodule(CheckerTestCase):

@staticmethod
def test_package_all() -> None:

sys.path.insert(0, REGR_DATA_DIR)
try:
linter.check([os.path.join(REGR_DATA_DIR, "package_all")])
Expand Down
2 changes: 0 additions & 2 deletions tests/lint/unittest_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,6 @@ def test_pylintrc() -> None:
@pytest.mark.usefixtures("pop_pylintrc")
def test_pylintrc_parentdir() -> None:
with tempdir() as chroot:

create_files(
[
"a/pylintrc",
Expand Down Expand Up @@ -1134,7 +1133,6 @@ def test_by_module_statement_value(initialized_linter: PyLinter) -> None:

by_module_stats = linter.stats.by_module
for module, module_stats in by_module_stats.items():

linter2 = initialized_linter
if module == "data":
linter2.check([os.path.join(os.path.dirname(__file__), "data/__init__.py")])
Expand Down
2 changes: 0 additions & 2 deletions tests/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def test_reporter_implements() -> None:
"""Test that __implements__ on BaseReporter has been deprecated correctly."""

class MyReporter(BaseReporter):

__implements__ = IReporter

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

class MyChecker(BaseChecker):

__implements__ = IAstroidChecker

with pytest.warns(DeprecationWarning):
Expand Down