diff options
| -rw-r--r-- | changelog.d/2592.change.rst | 4 | ||||
| -rw-r--r-- | setuptools/dist.py | 23 | ||||
| -rw-r--r-- | setuptools/tests/test_config.py | 5 |
3 files changed, 18 insertions, 14 deletions
diff --git a/changelog.d/2592.change.rst b/changelog.d/2592.change.rst index 3dbe816f..a38ae0c4 100644 --- a/changelog.d/2592.change.rst +++ b/changelog.d/2592.change.rst @@ -1 +1,3 @@ -Warned for usage of uppercase keys in :code:`metadata` in :code:`setup.cfg`, restored some compatiblity by transforming to lowercase if not. Followed the change of keys in :code:`setup.cfg` now being case-sensitive -- by :user:`melissa-kun-li`
\ No newline at end of file +Made option keys in the ``[metadata]`` section of ``setup.cfg`` case-sensitive. Users having +uppercase option spellings will get a warning suggesting to make them to lowercase +-- by :user:`melissa-kun-li` diff --git a/setuptools/dist.py b/setuptools/dist.py index 43a51ad8..70c0e6be 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -599,7 +599,7 @@ class Distribution(_Distribution): val = parser.get(section, opt) opt = self.dash_to_underscore_warning(opt, section) - opt = self.uppercase_warning(opt, section) + opt = self.make_option_lowercase(opt, section) opt_dict[opt] = (filename, val) # Make the ConfigParser forget everything (so we retain @@ -637,16 +637,17 @@ class Distribution(_Distribution): % (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 + def make_option_lowercase(self, opt, section): + if section != 'metadata' or opt.islower(): + return 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 # FIXME: 'Distribution._set_command_options' is too complex (14) def _set_command_options(self, command_obj, option_dict=None): # noqa: C901 diff --git a/setuptools/tests/test_config.py b/setuptools/tests/test_config.py index 454ffb24..1ff5ee41 100644 --- a/setuptools/tests/test_config.py +++ b/setuptools/tests/test_config.py @@ -541,8 +541,9 @@ class TestMetadata: with pytest.warns(UserWarning, match=msg): with get_dist(tmpdir) as dist: metadata = dist.metadata - assert metadata.name == 'foo' - assert metadata.description == 'Some description' + + assert metadata.name == 'foo' + assert metadata.description == 'Some description' class TestOptions: |
