Skip to content

Downgrade hyphen and uppercase deprecation warning to info #4923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/4923.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This changes ``enforce_underscore`` and ``enforce_option_lowercase`` from deprecation warnings to information only.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to read coherently in a change log.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so how do you suggest I word this?

Copy link
Author

@jamesliu4c jamesliu4c Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about,

Remove deprecation for dash-separated and uppercase fields in setup.cfg

?

If that is good, I'll patch that in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that looks like a TODO-list item because it uses infinitive. It's usually present simple or the past tense, explaining what the impact is for the end-user.

19 changes: 9 additions & 10 deletions setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,17 +628,16 @@ def _enforce_underscore(self, opt: str, section: str) -> str:

underscore_opt = opt.replace('-', '_')
affected = f"(Affected: {self.metadata.name})." if self.metadata.name else ""
SetuptoolsDeprecationWarning.emit(
InformationOnly.emit(
f"Invalid dash-separated key {opt!r} in {section!r} (setup.cfg), "
f"please use the underscore name {underscore_opt!r} instead.",
f"""
Usage of dash-separated {opt!r} will not be supported in future
versions. Please use the underscore name {underscore_opt!r} instead.
Usage of dash-separated {opt!r} is not supported by Python packaging
specifications. Please use the underscore name {underscore_opt!r} instead.
{affected}
""",
see_docs="userguide/declarative_config.html",
due_date=(2026, 3, 3),
# Warning initially introduced in 3 Mar 2021
# Changed from warning to info after https://github.com/pypa/setuptools/issues/4910
)
return underscore_opt

Expand All @@ -648,17 +647,17 @@ def _enforce_option_lowercase(self, opt: str, section: str) -> str:

lowercase_opt = opt.lower()
affected = f"(Affected: {self.metadata.name})." if self.metadata.name else ""
SetuptoolsDeprecationWarning.emit(
InformationOnly.emit(
f"Invalid uppercase key {opt!r} in {section!r} (setup.cfg), "
f"please use lowercase {lowercase_opt!r} instead.",
f"""
Usage of uppercase key {opt!r} in {section!r} will not be supported in
future versions. Please use lowercase {lowercase_opt!r} instead.
Usage of uppercase key {opt!r} in {section!r} is not supported
by Python packaging specifications. Please use lowercase {lowercase_opt!r}
instead.
{affected}
""",
see_docs="userguide/declarative_config.html",
due_date=(2026, 3, 3),
# Warning initially introduced in 6 Mar 2021
# Changed from warning to info after https://github.com/pypa/setuptools/issues/4910
)
return lowercase_opt

Expand Down
44 changes: 0 additions & 44 deletions setuptools/tests/config/test_setupcfg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import configparser
import contextlib
import inspect
import re
from pathlib import Path
from unittest.mock import Mock, patch

Expand Down Expand Up @@ -421,49 +420,6 @@ def test_not_utf8(self, tmpdir):
with get_dist(tmpdir):
pass

@pytest.mark.parametrize(
("error_msg", "config", "invalid"),
[
(
"Invalid dash-separated key 'author-email' in 'metadata' (setup.cfg)",
DALS(
"""
[metadata]
author-email = [email protected]
maintainer_email = [email protected]
"""
),
{"author-email": "[email protected]"},
),
(
"Invalid uppercase key 'Name' in 'metadata' (setup.cfg)",
DALS(
"""
[metadata]
Name = foo
description = Some description
"""
),
{"Name": "foo"},
),
],
)
def test_invalid_options_previously_deprecated(
self, tmpdir, error_msg, config, invalid
):
# This test and related methods can be removed when no longer needed.
# Deprecation postponed due to push-back from the community in
# https://github.com/pypa/setuptools/issues/4910
fake_env(tmpdir, config)
with pytest.warns(SetuptoolsDeprecationWarning, match=re.escape(error_msg)):
dist = get_dist(tmpdir).__enter__()

tmpdir.join('setup.cfg').remove()

for field, value in invalid.items():
attr = field.replace("-", "_").lower()
assert getattr(dist.metadata, attr) == value


class TestOptions:
def test_basic(self, tmpdir):
Expand Down