Skip to content

Commit 9705950

Browse files
[pre-commit.ci] pre-commit autoupdate (#2642)
updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.4 → v0.8.0](astral-sh/ruff-pre-commit@v0.7.4...v0.8.0)
1 parent 9efc827 commit 9705950

File tree

12 files changed

+47
-51
lines changed

12 files changed

+47
-51
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
- id: end-of-file-fixer
1111
exclude: tests/testdata
1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: "v0.7.4"
13+
rev: "v0.8.0"
1414
hooks:
1515
- id: ruff
1616
args: ["--fix"]

astroid/brain/brain_typing.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,16 @@ def _looks_like_special_alias(node: Call) -> bool:
358358
PY39: Callable = _CallableType(collections.abc.Callable, 2)
359359
"""
360360
return isinstance(node.func, Name) and (
361-
node.func.name == "_TupleType"
362-
and isinstance(node.args[0], Name)
363-
and node.args[0].name == "tuple"
364-
or node.func.name == "_CallableType"
365-
and isinstance(node.args[0], Attribute)
366-
and node.args[0].as_string() == "collections.abc.Callable"
361+
(
362+
node.func.name == "_TupleType"
363+
and isinstance(node.args[0], Name)
364+
and node.args[0].name == "tuple"
365+
)
366+
or (
367+
node.func.name == "_CallableType"
368+
and isinstance(node.args[0], Attribute)
369+
and node.args[0].as_string() == "collections.abc.Callable"
370+
)
367371
)
368372

369373

@@ -400,11 +404,8 @@ def infer_special_alias(
400404

401405

402406
def _looks_like_typing_cast(node: Call) -> bool:
403-
return (
404-
isinstance(node.func, Name)
405-
and node.func.name == "cast"
406-
or isinstance(node.func, Attribute)
407-
and node.func.attrname == "cast"
407+
return (isinstance(node.func, Name) and node.func.name == "cast") or (
408+
isinstance(node.func, Attribute) and node.func.attrname == "cast"
408409
)
409410

410411

astroid/context.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ class InferenceContext:
3737
"""
3838

3939
__slots__ = (
40-
"path",
41-
"lookupname",
42-
"callcontext",
40+
"_nodes_inferred",
4341
"boundnode",
44-
"extra_context",
42+
"callcontext",
4543
"constraints",
46-
"_nodes_inferred",
44+
"extra_context",
45+
"lookupname",
46+
"path",
4747
)
4848

4949
max_inferred = 100
@@ -164,7 +164,7 @@ def __str__(self) -> str:
164164
class CallContext:
165165
"""Holds information for a call site."""
166166

167-
__slots__ = ("args", "keywords", "callee")
167+
__slots__ = ("args", "callee", "keywords")
168168

169169
def __init__(
170170
self,

astroid/decorators.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,13 @@ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
147147
# - len(args) needs to be long enough, if too short
148148
# arg can't be in args either
149149
# - args[index] should not be None
150-
or arg not in kwargs
151-
and (
152-
index == -1
153-
or len(args) <= index
154-
or (len(args) > index and args[index] is None)
150+
or (
151+
arg not in kwargs
152+
and (
153+
index == -1
154+
or len(args) <= index
155+
or (len(args) > index and args[index] is None)
156+
)
155157
)
156158
):
157159
warnings.warn(

astroid/helpers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,8 @@ def object_len(node, context: InferenceContext | None = None):
300300
and result_of_len.pytype() == "builtins.int"
301301
):
302302
return result_of_len.value
303-
if (
304-
result_of_len is None
305-
or isinstance(result_of_len, bases.Instance)
303+
if result_of_len is None or (
304+
isinstance(result_of_len, bases.Instance)
306305
and result_of_len.is_subtype_of("builtins.int")
307306
):
308307
# Fake a result as we don't know the arguments of the instance call.

astroid/nodes/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,9 @@
202202
)
203203

204204
__all__ = (
205+
"CONST_CLS",
206+
"SYNTHETIC_ROOT",
205207
"AnnAssign",
206-
"are_exclusive",
207208
"Arguments",
208209
"Assert",
209210
"Assign",
@@ -219,20 +220,17 @@
219220
"BinOp",
220221
"BoolOp",
221222
"Break",
222-
"builtin_lookup",
223223
"Call",
224224
"ClassDef",
225-
"CONST_CLS",
226225
"Compare",
227226
"Comprehension",
228227
"ComprehensionScope",
229228
"Const",
230-
"const_factory",
231229
"Continue",
232230
"Decorators",
233231
"DelAttr",
234-
"Delete",
235232
"DelName",
233+
"Delete",
236234
"Dict",
237235
"DictComp",
238236
"DictUnpack",
@@ -243,9 +241,7 @@
243241
"For",
244242
"FormattedValue",
245243
"FunctionDef",
246-
"function_to_method",
247244
"GeneratorExp",
248-
"get_wrapping_class",
249245
"Global",
250246
"If",
251247
"IfExp",
@@ -277,7 +273,6 @@
277273
"Position",
278274
"Raise",
279275
"Return",
280-
"SYNTHETIC_ROOT",
281276
"Set",
282277
"SetComp",
283278
"Slice",
@@ -291,9 +286,14 @@
291286
"TypeVarTuple",
292287
"UnaryOp",
293288
"Unknown",
294-
"unpack_infer",
295289
"While",
296290
"With",
297291
"Yield",
298292
"YieldFrom",
293+
"are_exclusive",
294+
"builtin_lookup",
295+
"const_factory",
296+
"function_to_method",
297+
"get_wrapping_class",
298+
"unpack_infer",
299299
)

astroid/nodes/_base_nodes.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,13 +609,11 @@ def _get_binop_flow(
609609
and op == "|"
610610
and (
611611
isinstance(left, (bases.UnionType, nodes.ClassDef))
612-
or isinstance(left, nodes.Const)
613-
and left.value is None
612+
or (isinstance(left, nodes.Const) and left.value is None)
614613
)
615614
and (
616615
isinstance(right, (bases.UnionType, nodes.ClassDef))
617-
or isinstance(right, nodes.Const)
618-
and right.value is None
616+
or (isinstance(right, nodes.Const) and right.value is None)
619617
)
620618
):
621619
methods.extend([partial(OperatorNode._bin_op_or_union_type, left, right)])

astroid/nodes/as_string.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ def visit_while(self, node: nodes.While) -> str:
571571
def visit_with(self, node: nodes.With) -> str: # 'with' without 'as' is possible
572572
"""return an astroid.With node as string"""
573573
items = ", ".join(
574-
f"{expr.accept(self)}" + (v and f" as {v.accept(self)}" or "")
574+
f"{expr.accept(self)}" + ((v and f" as {v.accept(self)}") or "")
575575
for expr, v in node.items
576576
)
577577
return f"with {items}:\n{self._stmt_list(node.body)}"

astroid/nodes/node_classes.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4791,10 +4791,8 @@ def _infer_with_values(
47914791
) -> Generator[InferenceResult, None, InferenceErrorInfo | None]:
47924792
uninferable_already_generated = False
47934793
for inferred in self._infer_from_values(self.values, context):
4794-
failed = (
4795-
inferred is util.Uninferable
4796-
or isinstance(inferred, Const)
4797-
and UNINFERABLE_VALUE in inferred.value
4794+
failed = inferred is util.Uninferable or (
4795+
isinstance(inferred, Const) and UNINFERABLE_VALUE in inferred.value
47984796
)
47994797
if failed:
48004798
if not uninferable_already_generated:

astroid/nodes/scoped_nodes/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from astroid.nodes.scoped_nodes.utils import builtin_lookup
2929

3030
__all__ = (
31+
"SYNTHETIC_ROOT",
3132
"AsyncFunctionDef",
3233
"ClassDef",
3334
"ComprehensionScope",
@@ -38,10 +39,9 @@
3839
"ListComp",
3940
"LocalsDictNodeNG",
4041
"Module",
41-
"SYNTHETIC_ROOT",
4242
"SetComp",
43+
"_is_metaclass",
4344
"builtin_lookup",
4445
"function_to_method",
4546
"get_wrapping_class",
46-
"_is_metaclass",
4747
)

astroid/nodes/scoped_nodes/scoped_nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2128,7 +2128,7 @@ def scope_lookup(
21282128
)
21292129
if (
21302130
any(
2131-
node == base or base.parent_of(node) and not self.type_params
2131+
node == base or (base.parent_of(node) and not self.type_params)
21322132
for base in self.bases
21332133
)
21342134
or lookup_upper_frame

script/test_bump_changelog.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@
5050
)
5151
def test_get_next_version(version, version_type, expected_version, expected_versions):
5252
assert get_next_version(version, version_type) == expected_version
53-
if (
54-
version_type == VersionType.PATCH
55-
or version_type == VersionType.MINOR
56-
and version.endswith(".0")
53+
if version_type == VersionType.PATCH or (
54+
version_type == VersionType.MINOR and version.endswith(".0")
5755
):
5856
assert get_next_versions(version, version_type) == expected_versions
5957

0 commit comments

Comments
 (0)