Skip to content

Commit 890d6be

Browse files
authored
Merge pull request #2600 from melissa-kun-li/reduce_dash_deprecation_scope
Reduce scope of dash deprecation warning. Fixes #2595
2 parents b2f7b8f + 214ba3d commit 890d6be

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

changelog.d/2595.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reduced scope of dash deprecation warning to Setuptools/distutils only -- by :user:`melissa-kun-li`

setuptools/dist.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import distutils.core
1212
import distutils.cmd
1313
import distutils.dist
14+
import distutils.command
1415
from distutils.util import strtobool
1516
from distutils.debug import DEBUG
1617
from distutils.fancy_getopt import translate_longopt
@@ -29,6 +30,7 @@
2930
from . import SetuptoolsDeprecationWarning
3031

3132
import setuptools
33+
import setuptools.command
3234
from setuptools import windows_support
3335
from setuptools.monkey import get_unpatched
3436
from setuptools.config import parse_configuration
@@ -598,7 +600,7 @@ def _parse_config_files(self, filenames=None): # noqa: C901
598600
continue
599601

600602
val = parser.get(section, opt)
601-
opt = self.dash_to_underscore_warning(opt, section)
603+
opt = self.warn_dash_deprecation(opt, section)
602604
opt = self.make_option_lowercase(opt, section)
603605
opt_dict[opt] = (filename, val)
604606

@@ -624,12 +626,18 @@ def _parse_config_files(self, filenames=None): # noqa: C901
624626
except ValueError as e:
625627
raise DistutilsOptionError(e) from e
626628

627-
def dash_to_underscore_warning(self, opt, section):
629+
def warn_dash_deprecation(self, opt, section):
628630
if section in (
629631
'options.extras_require', 'options.data_files',
630632
):
631633
return opt
634+
632635
underscore_opt = opt.replace('-', '_')
636+
commands = distutils.command.__all__ + setuptools.command.__all__
637+
if (not section.startswith('options') and section != 'metadata'
638+
and section not in commands):
639+
return underscore_opt
640+
633641
if '-' in opt:
634642
warnings.warn(
635643
"Usage of dash-separated '%s' will not be supported in future "

setuptools/tests/test_config.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,9 @@ def test_not_utf8(self, tmpdir):
507507
with get_dist(tmpdir):
508508
pass
509509

510-
def test_dash_to_underscore_warning(self, tmpdir):
511-
# dash_to_underscore_warning() is a method in setuptools.dist
512-
# remove this test and method when dash convert to underscore in setup.cfg
513-
# is no longer supported
510+
def test_warn_dash_deprecation(self, tmpdir):
511+
# warn_dash_deprecation() is a method in setuptools.dist
512+
# remove this test and the method when no longer needed
514513
fake_env(
515514
tmpdir,
516515
'[metadata]\n'
@@ -523,11 +522,12 @@ def test_dash_to_underscore_warning(self, tmpdir):
523522
with pytest.warns(UserWarning, match=msg):
524523
with get_dist(tmpdir) as dist:
525524
metadata = dist.metadata
526-
assert metadata.author_email == '[email protected]'
527-
assert metadata.maintainer_email == '[email protected]'
528525

529-
def test_uppercase_warning(self, tmpdir):
530-
# remove this test and the method uppercase_warning() in setuptools.dist
526+
assert metadata.author_email == '[email protected]'
527+
assert metadata.maintainer_email == '[email protected]'
528+
529+
def test_make_option_lowercase(self, tmpdir):
530+
# remove this test and the method make_option_lowercase() in setuptools.dist
531531
# when no longer needed
532532
fake_env(
533533
tmpdir,

0 commit comments

Comments
 (0)