Skip to content

Commit 83c399a

Browse files
committed
Simplify _section_options using str.partition and a generator.
1 parent 997f671 commit 83c399a

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

setuptools/config/setupcfg.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def __init__(
253253
):
254254
self.ignore_option_errors = ignore_option_errors
255255
self.target_obj = target_obj
256-
self.sections = self._section_options(options)
256+
self.sections = dict(self._section_options(options))
257257
self.set_options: List[str] = []
258258
self.ensure_discovered = ensure_discovered
259259
self._referenced_files: Set[str] = set()
@@ -263,17 +263,11 @@ def __init__(
263263

264264
@classmethod
265265
def _section_options(cls, options: AllCommandOptions):
266-
sections: AllCommandOptions = {}
267-
268-
section_prefix = cls.section_prefix
269-
for section_name, section_options in options.items():
270-
if not section_name.startswith(section_prefix):
266+
for full_name, value in options.items():
267+
pre, sep, name = full_name.partition(cls.section_prefix)
268+
if pre:
271269
continue
272-
273-
section_name = section_name.replace(section_prefix, '').strip('.')
274-
sections[section_name] = section_options
275-
276-
return sections
270+
yield name.lstrip('.'), value
277271

278272
@property
279273
def parsers(self):

0 commit comments

Comments
 (0)