Skip to content

Commit 6b71893

Browse files
committed
Simplify negative conditions by applying DeMorgan's theorem
1 parent 5a9b4b5 commit 6b71893

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

setuptools/dist.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ def _parse_config_files(self, filenames=None): # noqa: C901
519519
raise DistutilsOptionError(e) from e
520520

521521
def _enforce_underscore(self, opt: str, section: str) -> str:
522-
if "-" not in opt or not self._config_requires_normalization(section):
522+
if "-" not in opt or self._skip_setupcfg_normalization(section):
523523
return opt
524524

525525
raise InvalidConfigError(
@@ -529,7 +529,7 @@ def _enforce_underscore(self, opt: str, section: str) -> str:
529529
)
530530

531531
def _enforce_option_lowercase(self, opt: str, section: str) -> str:
532-
if opt.islower() or not self._config_requires_normalization(section):
532+
if opt.islower() or self._skip_setupcfg_normalization(section):
533533
return opt
534534

535535
raise InvalidConfigError(
@@ -538,15 +538,15 @@ def _enforce_option_lowercase(self, opt: str, section: str) -> str:
538538
# Warning initially introduced in 6 Mar 2021
539539
)
540540

541-
def _config_requires_normalization(self, section: str) -> bool:
541+
def _skip_setupcfg_normalization(self, section: str) -> bool:
542542
skip = (
543543
'options.extras_require',
544544
'options.data_files',
545545
'options.entry_points',
546546
'options.package_data',
547547
'options.exclude_package_data',
548548
)
549-
return section not in skip and self._is_setuptools_section(section)
549+
return section in skip or not self._is_setuptools_section(section)
550550

551551
def _is_setuptools_section(self, section: str) -> bool:
552552
return (

0 commit comments

Comments
 (0)