Skip to content

Commit a2e9ae4

Browse files
Add compatibility method to warn for future underscore change
1 parent 8307bd4 commit a2e9ae4

File tree

Image for: File tree

1 file changed

Image for: 1 file changed
+16
-1
lines changed

1 file changed

Image for: 1 file changed
+16
-1
lines changed

‎setuptools/dist.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ def _parse_config_files(self, filenames=None): # noqa: C901
598598
continue
599599

600600
val = parser.get(section, opt)
601-
opt = opt.replace('-', '_')
601+
opt = self.dash_to_underscore_warning(opt)
602602
opt_dict[opt] = (filename, val)
603603

604604
# Make the ConfigParser forget everything (so we retain
@@ -623,6 +623,21 @@ def _parse_config_files(self, filenames=None): # noqa: C901
623623
except ValueError as e:
624624
raise DistutilsOptionError(e) from e
625625

626+
def dash_to_underscore_warning(self, opt):
627+
if opt in (
628+
'home-page', 'download-url', 'author-email',
629+
'maintainer-email', 'long-description', 'build-base',
630+
'project-urls', 'license-file', 'license-files',
631+
'long-description-content-type',
632+
):
633+
underscore_opt = opt.replace('-', '_')
634+
warnings.warn(
635+
"Usage of dash-separated '%s' will not be supported in future "
636+
"versions. Please use the underscore name '%s' instead"
637+
% (opt, underscore_opt))
638+
return underscore_opt
639+
return opt
640+
626641
# FIXME: 'Distribution._set_command_options' is too complex (14)
627642
def _set_command_options(self, command_obj, option_dict=None): # noqa: C901
628643
"""

0 commit comments

Image for: 0 commit comments
Comments
 (0)