Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#2262)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.278 → v0.0.280](astral-sh/ruff-pre-commit@v0.0.278...v0.0.280)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] committed Jul 25, 2023
1 parent 00d7940 commit 44c1ebb
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: end-of-file-fixer
exclude: tests/testdata
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.278"
rev: "v0.0.280"
hooks:
- id: ruff
exclude: tests/testdata
Expand Down
2 changes: 1 addition & 1 deletion tests/brain/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def getter():
asd = property(getter) #@
"""
)
inferred_property = list(class_with_property.value.infer())[0]
inferred_property = next(iter(class_with_property.value.infer()))
self.assertTrue(isinstance(inferred_property, objects.Property))
class_parent = inferred_property.parent.parent.parent
self.assertIsInstance(class_parent, nodes.ClassDef)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -4946,7 +4946,7 @@ def __class_getitem__(self, value):
context = InferenceContext()
_ = klass.getitem(0, context=context)

assert list(context.path)[0][0].name == "Parent"
assert next(iter(context.path))[0].name == "Parent"


class TestType(unittest.TestCase):
Expand Down
54 changes: 27 additions & 27 deletions tests/test_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@ def initialize(linter):
''',
"data.__init__",
)
path = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "__path__"][
0
]
path = next(
n for n in astroid.nodes_of_class(nodes.Name) if n.name == "__path__"
)
self.assertEqual(len(path.lookup("__path__")[1]), 1)

def test_builtin_lookup(self) -> None:
Expand Down Expand Up @@ -477,7 +477,7 @@ def test_consecutive_assign(self) -> None:
print(x)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 1)
self.assertEqual(stmts[0].lineno, 3)
Expand All @@ -489,7 +489,7 @@ def test_assign_after_use(self) -> None:
x = 10
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 0)

Expand All @@ -501,7 +501,7 @@ def test_del_removes_prior(self) -> None:
print(x)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 0)

Expand All @@ -514,7 +514,7 @@ def test_del_no_effect_after(self) -> None:
print(x)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 1)
self.assertEqual(stmts[0].lineno, 4)
Expand All @@ -531,7 +531,7 @@ def f(b):
print(x)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 2)
self.assertCountEqual([stmt.lineno for stmt in stmts], [3, 5])
Expand All @@ -549,7 +549,7 @@ def f(b):
print(x)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 2)
self.assertCountEqual([stmt.lineno for stmt in stmts], [3, 6])
Expand All @@ -571,7 +571,7 @@ def f(b):
print(x)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 4)
self.assertCountEqual([stmt.lineno for stmt in stmts], [3, 6, 8, 10])
Expand All @@ -594,7 +594,7 @@ def f(b):
print(x)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 1)
self.assertEqual(stmts[0].lineno, 3)
Expand All @@ -618,7 +618,7 @@ def f(b):
x = 5
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 1)
self.assertEqual(stmts[0].lineno, 10)
Expand All @@ -640,7 +640,7 @@ def f(b):
print(x)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 3)
self.assertCountEqual([stmt.lineno for stmt in stmts], [3, 5, 7])
Expand Down Expand Up @@ -710,7 +710,7 @@ def f(b):
print(x)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 1)
self.assertEqual(stmts[0].lineno, 9)
Expand All @@ -730,7 +730,7 @@ def f(b):
print(x)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 1)
self.assertEqual(stmts[0].lineno, 3)
Expand Down Expand Up @@ -829,14 +829,14 @@ def f(*args, **kwargs):
print(args, kwargs)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "args"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "args")
_, stmts1 = x_name.lookup("args")
self.assertEqual(len(stmts1), 1)
self.assertEqual(stmts1[0].lineno, 3)

x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "kwargs"][
0
]
x_name = next(
n for n in astroid.nodes_of_class(nodes.Name) if n.name == "kwargs"
)
_, stmts2 = x_name.lookup("kwargs")
self.assertEqual(len(stmts2), 1)
self.assertEqual(stmts2[0].lineno, 4)
Expand All @@ -852,7 +852,7 @@ def test_except_var_in_block(self) -> None:
print(e)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "e"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "e")
_, stmts = x_name.lookup("e")
self.assertEqual(len(stmts), 1)
self.assertEqual(stmts[0].lineno, 4)
Expand All @@ -870,7 +870,7 @@ def test_except_var_in_block_overwrites(self) -> None:
print(e)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "e"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "e")
_, stmts = x_name.lookup("e")
self.assertEqual(len(stmts), 1)
self.assertEqual(stmts[0].lineno, 5)
Expand Down Expand Up @@ -912,7 +912,7 @@ def test_except_var_after_block_single(self) -> None:
print(e)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "e"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "e")
_, stmts = x_name.lookup("e")
self.assertEqual(len(stmts), 0)

Expand All @@ -930,7 +930,7 @@ def test_except_var_after_block_multiple(self) -> None:
print(e)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "e"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "e")
_, stmts = x_name.lookup("e")
self.assertEqual(len(stmts), 0)

Expand All @@ -946,7 +946,7 @@ def test_except_assign_in_block(self) -> None:
print(x)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 1)
self.assertEqual(stmts[0].lineno, 5)
Expand All @@ -965,7 +965,7 @@ def test_except_assign_in_block_multiple(self) -> None:
print(x)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 1)
self.assertEqual(stmts[0].lineno, 7)
Expand All @@ -984,7 +984,7 @@ def test_except_assign_after_block(self) -> None:
print(x)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 2)
self.assertCountEqual([stmt.lineno for stmt in stmts], [5, 7])
Expand All @@ -1004,7 +1004,7 @@ def test_except_assign_after_block_overwritten(self) -> None:
print(x)
"""
astroid = builder.parse(code)
x_name = [n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x"][0]
x_name = next(n for n in astroid.nodes_of_class(nodes.Name) if n.name == "x")
_, stmts = x_name.lookup("x")
self.assertEqual(len(stmts), 1)
self.assertEqual(stmts[0].lineno, 8)
2 changes: 1 addition & 1 deletion tests/test_scoped_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def f():
g = lambda: None
"""
astroid = builder.parse(data)
g = list(astroid["f"].ilookup("g"))[0]
g = next(iter(astroid["f"].ilookup("g")))
self.assertEqual(g.pytype(), "builtins.function")

def test_lambda_qname(self) -> None:
Expand Down

0 comments on commit 44c1ebb

Please sign in to comment.