diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2023-03-05 22:19:48 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2023-03-05 22:19:48 -0500 |
commit | 83c399a3498b7855746ec640710fa2002afb31bd (patch) | |
tree | 66a593b941ed1bb2db72815761a581176950991f | |
parent | 997f671dbf64a5273968ce0f53a2369fd7abbee3 (diff) | |
download | python-setuptools-git-83c399a3498b7855746ec640710fa2002afb31bd.tar.gz |
Simplify _section_options using str.partition and a generator.
-rw-r--r-- | setuptools/config/setupcfg.py | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/setuptools/config/setupcfg.py b/setuptools/config/setupcfg.py index 1b617013..03a446fd 100644 --- a/setuptools/config/setupcfg.py +++ b/setuptools/config/setupcfg.py @@ -253,7 +253,7 @@ class ConfigHandler(Generic[Target]): ): 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() @@ -263,17 +263,11 @@ class ConfigHandler(Generic[Target]): @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): |