From 938a33922c8cba3bbff6dfd1c2f723e5f929d6ce Mon Sep 17 00:00:00 2001 From: Melissa Li Date: Mon, 8 Mar 2021 02:59:16 -0500 Subject: [PATCH 1/3] Reduce scope of dash deprecation warning to Setuptools and distutils --- setuptools/dist.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/setuptools/dist.py b/setuptools/dist.py index 70c0e6becb..d1587e3415 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -11,6 +11,7 @@ import distutils.core import distutils.cmd import distutils.dist +import distutils.command from distutils.util import strtobool from distutils.debug import DEBUG from distutils.fancy_getopt import translate_longopt @@ -29,6 +30,7 @@ from . import SetuptoolsDeprecationWarning import setuptools +import setuptools.command from setuptools import windows_support from setuptools.monkey import get_unpatched from setuptools.config import parse_configuration @@ -629,7 +631,13 @@ def dash_to_underscore_warning(self, opt, section): 'options.extras_require', 'options.data_files', ): return opt + underscore_opt = opt.replace('-', '_') + commands = distutils.command.__all__ + setuptools.command.__all__ + if (not section.startswith('options') and section != 'metadata' + and section not in commands): + return underscore_opt + if '-' in opt: warnings.warn( "Usage of dash-separated '%s' will not be supported in future " From 7129ad1107f7015fe16f275eec17bf36a8badd84 Mon Sep 17 00:00:00 2001 From: Melissa Li Date: Mon, 8 Mar 2021 03:25:14 -0500 Subject: [PATCH 2/3] Fix formatting of tests and change dash deprecation method name --- setuptools/dist.py | 4 ++-- setuptools/tests/test_config.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/setuptools/dist.py b/setuptools/dist.py index d1587e3415..7cebcb37f4 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -600,7 +600,7 @@ def _parse_config_files(self, filenames=None): # noqa: C901 continue val = parser.get(section, opt) - opt = self.dash_to_underscore_warning(opt, section) + opt = self.warn_dash_deprecation(opt, section) opt = self.make_option_lowercase(opt, section) opt_dict[opt] = (filename, val) @@ -626,7 +626,7 @@ 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, section): + def warn_dash_deprecation(self, opt, section): if section in ( 'options.extras_require', 'options.data_files', ): diff --git a/setuptools/tests/test_config.py b/setuptools/tests/test_config.py index 1ff5ee4185..21f1becd49 100644 --- a/setuptools/tests/test_config.py +++ b/setuptools/tests/test_config.py @@ -507,10 +507,9 @@ def test_not_utf8(self, tmpdir): with get_dist(tmpdir): pass - def test_dash_to_underscore_warning(self, tmpdir): - # dash_to_underscore_warning() is a method in setuptools.dist - # remove this test and method when dash convert to underscore in setup.cfg - # is no longer supported + def test_warn_dash_deprecation(self, tmpdir): + # warn_dash_deprecation() is a method in setuptools.dist + # remove this test and the method when no longer needed fake_env( tmpdir, '[metadata]\n' @@ -523,11 +522,12 @@ def test_dash_to_underscore_warning(self, tmpdir): with pytest.warns(UserWarning, match=msg): with get_dist(tmpdir) as dist: metadata = dist.metadata - assert metadata.author_email == 'test@test.com' - assert metadata.maintainer_email == 'foo@foo.com' - def test_uppercase_warning(self, tmpdir): - # remove this test and the method uppercase_warning() in setuptools.dist + assert metadata.author_email == 'test@test.com' + assert metadata.maintainer_email == 'foo@foo.com' + + def test_make_option_lowercase(self, tmpdir): + # remove this test and the method make_option_lowercase() in setuptools.dist # when no longer needed fake_env( tmpdir, From 214ba3de5cf8bf6cdff824059732eebd26f3d40c Mon Sep 17 00:00:00 2001 From: Melissa Li Date: Mon, 8 Mar 2021 03:41:04 -0500 Subject: [PATCH 3/3] Add changelog --- changelog.d/2595.misc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/2595.misc.rst diff --git a/changelog.d/2595.misc.rst b/changelog.d/2595.misc.rst new file mode 100644 index 0000000000..976117dc9a --- /dev/null +++ b/changelog.d/2595.misc.rst @@ -0,0 +1 @@ +Reduced scope of dash deprecation warning to Setuptools/distutils only -- by :user:`melissa-kun-li` \ No newline at end of file