Skip to content

Commit cffbd73

Browse files
authored
Modernise some syntax in setupcfg.py (#4697)
2 parents 31decc9 + 446e58f commit cffbd73

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

setuptools/config/setupcfg.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def __setitem__(self, option_name, value) -> None:
304304
return
305305

306306
simple_setter = functools.partial(target_obj.__setattr__, option_name)
307-
setter = getattr(target_obj, 'set_%s' % option_name, simple_setter)
307+
setter = getattr(target_obj, f"set_{option_name}", simple_setter)
308308
setter(parsed)
309309

310310
self.set_options.append(option_name)
@@ -372,8 +372,8 @@ def parser(value):
372372
exclude_directive = 'file:'
373373
if value.startswith(exclude_directive):
374374
raise ValueError(
375-
'Only strings are accepted for the {0} field, '
376-
'files are not accepted'.format(key)
375+
f'Only strings are accepted for the {key} field, '
376+
'files are not accepted'
377377
)
378378
return value
379379

@@ -491,12 +491,12 @@ def parse(self) -> None:
491491
for section_name, section_options in self.sections.items():
492492
method_postfix = ''
493493
if section_name: # [section.option] variant
494-
method_postfix = '_%s' % section_name
494+
method_postfix = f"_{section_name}"
495495

496496
section_parser_method: Callable | None = getattr(
497497
self,
498498
# Dots in section names are translated into dunderscores.
499-
('parse_section%s' % method_postfix).replace('.', '__'),
499+
f'parse_section{method_postfix}'.replace('.', '__'),
500500
None,
501501
)
502502

@@ -701,10 +701,7 @@ def parse_section_packages__find(self, section_options):
701701
section_data = self._parse_section_to_dict(section_options, self._parse_list)
702702

703703
valid_keys = ['where', 'include', 'exclude']
704-
705-
find_kwargs = dict([
706-
(k, v) for k, v in section_data.items() if k in valid_keys and v
707-
])
704+
find_kwargs = {k: v for k, v in section_data.items() if k in valid_keys and v}
708705

709706
where = find_kwargs.get('where')
710707
if where is not None:

0 commit comments

Comments
 (0)