Skip to content

Commit

Permalink
Black 24
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Jan 26, 2024
1 parent 2087b3b commit 75d54c2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:

repos:
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.1.0
hooks:
- id: black

Expand Down
50 changes: 28 additions & 22 deletions src/attr/_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,17 @@ def astuple(
elif isinstance(v, (tuple, list, set, frozenset)):
cf = v.__class__ if retain is True else list
items = [
astuple(
j,
recurse=True,
filter=filter,
tuple_factory=tuple_factory,
retain_collection_types=retain,
(
astuple(
j,
recurse=True,
filter=filter,
tuple_factory=tuple_factory,
retain_collection_types=retain,
)
if has(j.__class__)
else j
)
if has(j.__class__)
else j
for j in v
]
try:
Expand All @@ -272,20 +274,24 @@ def astuple(
rv.append(
df(
(
astuple(
kk,
tuple_factory=tuple_factory,
retain_collection_types=retain,
)
if has(kk.__class__)
else kk,
astuple(
vv,
tuple_factory=tuple_factory,
retain_collection_types=retain,
)
if has(vv.__class__)
else vv,
(
astuple(
kk,
tuple_factory=tuple_factory,
retain_collection_types=retain,
)
if has(kk.__class__)
else kk
),
(
astuple(
vv,
tuple_factory=tuple_factory,
retain_collection_types=retain,
)
if has(vv.__class__)
else vv
),
)
for kk, vv in v.items()
)
Expand Down
26 changes: 14 additions & 12 deletions src/attr/_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -2387,9 +2387,9 @@ def fmt_setter_with_converter(
attr_name, arg_name, has_on_setattr
)
)
names_for_globals[
_init_converter_pat % (a.name,)
] = a.converter
names_for_globals[_init_converter_pat % (a.name,)] = (
a.converter
)
else:
lines.append(fmt_setter(attr_name, arg_name, has_on_setattr))

Expand Down Expand Up @@ -2418,9 +2418,9 @@ def fmt_setter_with_converter(
has_on_setattr,
)
)
names_for_globals[
_init_converter_pat % (a.name,)
] = a.converter
names_for_globals[_init_converter_pat % (a.name,)] = (
a.converter
)
else:
lines.append(
" " + fmt_setter(attr_name, arg_name, has_on_setattr)
Expand All @@ -2447,9 +2447,9 @@ def fmt_setter_with_converter(
attr_name, arg_name, has_on_setattr
)
)
names_for_globals[
_init_converter_pat % (a.name,)
] = a.converter
names_for_globals[_init_converter_pat % (a.name,)] = (
a.converter
)
else:
lines.append(fmt_setter(attr_name, arg_name, has_on_setattr))

Expand Down Expand Up @@ -2735,9 +2735,11 @@ def _setattrs(self, name_values_pairs):
else:
bound_setattr(
name,
types.MappingProxyType(dict(value))
if value
else _empty_metadata_singleton,
(
types.MappingProxyType(dict(value))
if value
else _empty_metadata_singleton
),
)


Expand Down
3 changes: 1 addition & 2 deletions tests/test_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,4 @@ def test_attrsinstance_subclass_protocol():
"""

class Foo(attr.AttrsInstance, attr._compat.Protocol):
def attribute(self) -> int:
...
def attribute(self) -> int: ...
8 changes: 5 additions & 3 deletions tests/test_dunders.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ def _add_init(cls, frozen):
cls,
cls.__attrs_attrs__,
has_pre_init,
len(inspect.signature(cls.__attrs_pre_init__).parameters) > 1
if has_pre_init
else False,
(
len(inspect.signature(cls.__attrs_pre_init__).parameters) > 1
if has_pre_init
else False
),
getattr(cls, "__attrs_post_init__", False),
frozen,
_is_slot_cls(cls),
Expand Down

0 comments on commit 75d54c2

Please sign in to comment.