Skip to content

Commit

Permalink
Add compatibility method to warn for future underscore change
Browse files Browse the repository at this point in the history
  • Loading branch information
melissa-kun-li committed Mar 3, 2021
1 parent 8307bd4 commit a2e9ae4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion setuptools/dist.py
Expand Up @@ -598,7 +598,7 @@ def _parse_config_files(self, filenames=None): # noqa: C901
continue

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

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

def dash_to_underscore_warning(self, opt):
if opt in (
'home-page', 'download-url', 'author-email',
'maintainer-email', 'long-description', 'build-base',
'project-urls', 'license-file', 'license-files',
'long-description-content-type',
):
underscore_opt = opt.replace('-', '_')
warnings.warn(
"Usage of dash-separated '%s' will not be supported in future "
"versions. Please use the underscore name '%s' instead"
% (opt, underscore_opt))
return underscore_opt
return opt

# FIXME: 'Distribution._set_command_options' is too complex (14)
def _set_command_options(self, command_obj, option_dict=None): # noqa: C901
"""
Expand Down

0 comments on commit a2e9ae4

Please sign in to comment.