Skip to content

Commit 958e9e9

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d6f2d8c commit 958e9e9

File tree

3 files changed

+10
-24
lines changed

3 files changed

+10
-24
lines changed

src/attr/_make.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,9 +1979,9 @@ def _make_repr(attrs, ns, cls):
19791979
"self." + name if i else 'getattr(self, "' + name + '", NOTHING)'
19801980
)
19811981
fragment = (
1982-
"{}={{{}!r}}".format(name, accessor)
1982+
f"{name}={{{accessor}!r}}"
19831983
if r == repr
1984-
else "{}={{{}_repr({})}}".format(name, name, accessor)
1984+
else f"{name}={{{name}_repr({accessor})}}"
19851985
)
19861986
attribute_fragments.append(fragment)
19871987
repr_fragment = ", ".join(attribute_fragments)
@@ -2208,11 +2208,7 @@ def _setattr_with_converter(attr_name, value_var, has_on_setattr):
22082208
Use the cached object.setattr to set *attr_name* to *value_var*, but run
22092209
its converter first.
22102210
"""
2211-
return "_setattr('{}', {}({}))".format(
2212-
attr_name,
2213-
_INIT_CONVERTER_PAT % (attr_name,),
2214-
value_var,
2215-
)
2211+
return f"_setattr('{attr_name}', {_INIT_CONVERTER_PAT % (attr_name,)}({value_var}))"
22162212

22172213

22182214
def _assign(attr_name, value, has_on_setattr):
@@ -2234,11 +2230,7 @@ def _assign_with_converter(attr_name, value_var, has_on_setattr):
22342230
if has_on_setattr:
22352231
return _setattr_with_converter(attr_name, value_var, True)
22362232

2237-
return "self.{} = {}({})".format(
2238-
attr_name,
2239-
_INIT_CONVERTER_PAT % (attr_name,),
2240-
value_var,
2241-
)
2233+
return f"self.{attr_name} = {_INIT_CONVERTER_PAT % (attr_name,)}({value_var})"
22422234

22432235

22442236
def _determine_setters(frozen, slots, base_attr_map):
@@ -2267,11 +2259,7 @@ def fmt_setter_with_converter(attr_name, value_var, has_on_setattr):
22672259
attr_name, value_var, has_on_setattr
22682260
)
22692261

2270-
return "_inst_dict['{}'] = {}({})".format(
2271-
attr_name,
2272-
_INIT_CONVERTER_PAT % (attr_name,),
2273-
value_var,
2274-
)
2262+
return f"_inst_dict['{attr_name}'] = {_INIT_CONVERTER_PAT % (attr_name,)}({value_var})"
22752263

22762264
return (
22772265
("_inst_dict = self.__dict__",),
@@ -2519,7 +2507,7 @@ def _attrs_to_init_script(
25192507
", ".join(kw_only_args), # kw_only args
25202508
)
25212509
pre_init_kw_only_args = ", ".join(
2522-
["{}={}".format(kw_arg, kw_arg) for kw_arg in kw_only_args]
2510+
[f"{kw_arg}={kw_arg}" for kw_arg in kw_only_args]
25232511
)
25242512
pre_init_args += (
25252513
", " if pre_init_args else ""

tests/test_packaging.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# SPDX-License-Identifier: MIT
22

3-
import sys
3+
4+
from importlib import metadata
45

56
import pytest
67

78
import attr
89
import attrs
910

1011

11-
from importlib import metadata
12-
13-
1412
@pytest.fixture(name="mod", params=(attr, attrs))
1513
def _mod(request):
1614
return request.param

tests/test_slots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ class C:
597597
field = attr.ib()
598598

599599
def f(self, a):
600-
super().__init__() # noqa: UP008
600+
super().__init__()
601601

602602
C(field=1)
603603

@@ -685,7 +685,7 @@ def f(self):
685685
class C(A):
686686
@property
687687
def f(self):
688-
return super().f ** 2 # noqa: UP008
688+
return super().f ** 2
689689

690690
assert B(11).f == 121
691691
assert B(17).f == 289

0 commit comments

Comments
 (0)