Skip to content

Commit 75d54c2

Browse files
committed
Black 24
1 parent 2087b3b commit 75d54c2

File tree

5 files changed

+49
-40
lines changed

5 files changed

+49
-40
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44

55
repos:
66
- repo: https://github.com/psf/black
7-
rev: 23.12.1
7+
rev: 24.1.0
88
hooks:
99
- id: black
1010

src/attr/_funcs.py

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,17 @@ def astuple(
248248
elif isinstance(v, (tuple, list, set, frozenset)):
249249
cf = v.__class__ if retain is True else list
250250
items = [
251-
astuple(
252-
j,
253-
recurse=True,
254-
filter=filter,
255-
tuple_factory=tuple_factory,
256-
retain_collection_types=retain,
251+
(
252+
astuple(
253+
j,
254+
recurse=True,
255+
filter=filter,
256+
tuple_factory=tuple_factory,
257+
retain_collection_types=retain,
258+
)
259+
if has(j.__class__)
260+
else j
257261
)
258-
if has(j.__class__)
259-
else j
260262
for j in v
261263
]
262264
try:
@@ -272,20 +274,24 @@ def astuple(
272274
rv.append(
273275
df(
274276
(
275-
astuple(
276-
kk,
277-
tuple_factory=tuple_factory,
278-
retain_collection_types=retain,
279-
)
280-
if has(kk.__class__)
281-
else kk,
282-
astuple(
283-
vv,
284-
tuple_factory=tuple_factory,
285-
retain_collection_types=retain,
286-
)
287-
if has(vv.__class__)
288-
else vv,
277+
(
278+
astuple(
279+
kk,
280+
tuple_factory=tuple_factory,
281+
retain_collection_types=retain,
282+
)
283+
if has(kk.__class__)
284+
else kk
285+
),
286+
(
287+
astuple(
288+
vv,
289+
tuple_factory=tuple_factory,
290+
retain_collection_types=retain,
291+
)
292+
if has(vv.__class__)
293+
else vv
294+
),
289295
)
290296
for kk, vv in v.items()
291297
)

src/attr/_make.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,9 +2387,9 @@ def fmt_setter_with_converter(
23872387
attr_name, arg_name, has_on_setattr
23882388
)
23892389
)
2390-
names_for_globals[
2391-
_init_converter_pat % (a.name,)
2392-
] = a.converter
2390+
names_for_globals[_init_converter_pat % (a.name,)] = (
2391+
a.converter
2392+
)
23932393
else:
23942394
lines.append(fmt_setter(attr_name, arg_name, has_on_setattr))
23952395

@@ -2418,9 +2418,9 @@ def fmt_setter_with_converter(
24182418
has_on_setattr,
24192419
)
24202420
)
2421-
names_for_globals[
2422-
_init_converter_pat % (a.name,)
2423-
] = a.converter
2421+
names_for_globals[_init_converter_pat % (a.name,)] = (
2422+
a.converter
2423+
)
24242424
else:
24252425
lines.append(
24262426
" " + fmt_setter(attr_name, arg_name, has_on_setattr)
@@ -2447,9 +2447,9 @@ def fmt_setter_with_converter(
24472447
attr_name, arg_name, has_on_setattr
24482448
)
24492449
)
2450-
names_for_globals[
2451-
_init_converter_pat % (a.name,)
2452-
] = a.converter
2450+
names_for_globals[_init_converter_pat % (a.name,)] = (
2451+
a.converter
2452+
)
24532453
else:
24542454
lines.append(fmt_setter(attr_name, arg_name, has_on_setattr))
24552455

@@ -2735,9 +2735,11 @@ def _setattrs(self, name_values_pairs):
27352735
else:
27362736
bound_setattr(
27372737
name,
2738-
types.MappingProxyType(dict(value))
2739-
if value
2740-
else _empty_metadata_singleton,
2738+
(
2739+
types.MappingProxyType(dict(value))
2740+
if value
2741+
else _empty_metadata_singleton
2742+
),
27412743
)
27422744

27432745

tests/test_compat.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,4 @@ def test_attrsinstance_subclass_protocol():
6060
"""
6161

6262
class Foo(attr.AttrsInstance, attr._compat.Protocol):
63-
def attribute(self) -> int:
64-
...
63+
def attribute(self) -> int: ...

tests/test_dunders.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ def _add_init(cls, frozen):
9191
cls,
9292
cls.__attrs_attrs__,
9393
has_pre_init,
94-
len(inspect.signature(cls.__attrs_pre_init__).parameters) > 1
95-
if has_pre_init
96-
else False,
94+
(
95+
len(inspect.signature(cls.__attrs_pre_init__).parameters) > 1
96+
if has_pre_init
97+
else False
98+
),
9799
getattr(cls, "__attrs_post_init__", False),
98100
frozen,
99101
_is_slot_cls(cls),

0 commit comments

Comments
 (0)