Skip to content

Commit

Permalink
Warn for uppercase usage in setup.cfg metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
melissa-kun-li committed Mar 6, 2021
1 parent 23ee037 commit 132a6cd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ def _parse_config_files(self, filenames=None): # noqa: C901

val = parser.get(section, opt)
opt = self.dash_to_underscore_warning(opt, section)
opt = self.uppercase_warning(opt, section)
opt_dict[opt] = (filename, val)

# Make the ConfigParser forget everything (so we retain
Expand Down Expand Up @@ -636,6 +637,17 @@ def dash_to_underscore_warning(self, opt, section):
% (opt, underscore_opt))
return underscore_opt

def uppercase_warning(self, opt, section):
if section in ('metadata',) and (any(c.isupper() for c in opt)):
lowercase_opt = opt.lower()
warnings.warn(
"Usage of uppercase key '%s' in '%s' will be deprecated in future "
"versions. Please use lowercase '%s' instead"
% (opt, section, lowercase_opt)
)
return lowercase_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 132a6cd

Please sign in to comment.