Skip to content

Commit

Permalink
Simplify _section_options using str.partition and a generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Mar 6, 2023
1 parent 997f671 commit 83c399a
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions setuptools/config/setupcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def __init__(
):
self.ignore_option_errors = ignore_option_errors
self.target_obj = target_obj
self.sections = self._section_options(options)
self.sections = dict(self._section_options(options))
self.set_options: List[str] = []
self.ensure_discovered = ensure_discovered
self._referenced_files: Set[str] = set()
Expand All @@ -263,17 +263,11 @@ def __init__(

@classmethod
def _section_options(cls, options: AllCommandOptions):
sections: AllCommandOptions = {}

section_prefix = cls.section_prefix
for section_name, section_options in options.items():
if not section_name.startswith(section_prefix):
for full_name, value in options.items():
pre, sep, name = full_name.partition(cls.section_prefix)
if pre:
continue

section_name = section_name.replace(section_prefix, '').strip('.')
sections[section_name] = section_options

return sections
yield name.lstrip('.'), value

@property
def parsers(self):
Expand Down

0 comments on commit 83c399a

Please sign in to comment.