-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Disallow deprecated dash-separated and uppercase options in setup.cfg #4870
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
88bee15
Disalow deprecated dash-separated and uppercase options in setup.cfg
abravalheri 3a0596f
Add news fragment
abravalheri a67f998
Avoid duplication in setuptools.dist
abravalheri 5a9b4b5
Update mentions to PEP in newsfragment
abravalheri 6b71893
Simplify negative conditions by applying DeMorgan's theorem
abravalheri d364057
Fix error in `setuptools/dist.py`
abravalheri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Setuptools no longer accepts options containing uppercase or dash characters in ``setup.cfg``. | ||
Please ensure to write the options in ``setup.cfg`` using the :wiki:`lower_snake_case <Snake_case>` convention | ||
(e.g. ``Name => name``, ``install-requires => install_requires``). | ||
This is a follow-up on deprecations introduced in | ||
`v54.1.0 <https://setuptools.pypa.io/en/latest/history.html#v54-1-0>`_ (see #1608) and | ||
`v54.1.1 <https://setuptools.pypa.io/en/latest/history.html#v54-1-1>`_ (see #2592). | ||
|
||
.. note:: | ||
This change *does not affect configurations in* ``pyproject.toml`` | ||
(which uses the :wiki:`lower-kebab-case <Letter_case#Kebab_case>` convention following the precedent set in :pep:`517`/:pep:`518`). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import configparser | ||
import contextlib | ||
import inspect | ||
import re | ||
from pathlib import Path | ||
from unittest.mock import Mock, patch | ||
|
||
|
@@ -9,6 +10,7 @@ | |
|
||
from setuptools.config.setupcfg import ConfigHandler, Target, read_configuration | ||
from setuptools.dist import Distribution, _Distribution | ||
from setuptools.errors import InvalidConfigError | ||
from setuptools.warnings import SetuptoolsDeprecationWarning | ||
|
||
from ..textwrap import DALS | ||
|
@@ -420,36 +422,36 @@ def test_not_utf8(self, tmpdir): | |
with get_dist(tmpdir): | ||
pass | ||
|
||
@pytest.mark.xfail(reason="#4864") | ||
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' | ||
'author-email = [email protected]\n' | ||
'maintainer_email = foo@foo.com\n', | ||
) | ||
msg = "Usage of dash-separated 'author-email' will not be supported" | ||
with pytest.warns(SetuptoolsDeprecationWarning, match=msg): | ||
with get_dist(tmpdir) as dist: | ||
metadata = dist.metadata | ||
|
||
assert metadata.author_email == '[email protected]' | ||
assert metadata.maintainer_email == '[email protected]' | ||
|
||
@pytest.mark.xfail(reason="#4864") | ||
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, '[metadata]\nName = foo\ndescription = Some description\n') | ||
msg = "Usage of uppercase key 'Name' in 'metadata' will not be supported" | ||
with pytest.warns(SetuptoolsDeprecationWarning, match=msg): | ||
with get_dist(tmpdir) as dist: | ||
metadata = dist.metadata | ||
|
||
assert metadata.name == 'foo' | ||
assert metadata.description == 'Some description' | ||
@pytest.mark.parametrize( | ||
("error_msg", "config"), | ||
[ | ||
( | ||
"Invalid dash-separated key 'author-email' in 'metadata' (setup.cfg)", | ||
DALS( | ||
""" | ||
[metadata] | ||
author-email = test@test.com | ||
maintainer_email = [email protected] | ||
""" | ||
), | ||
), | ||
( | ||
"Invalid uppercase key 'Name' in 'metadata' (setup.cfg)", | ||
DALS( | ||
""" | ||
[metadata] | ||
Name = foo | ||
description = Some description | ||
""" | ||
), | ||
), | ||
], | ||
) | ||
def test_invalid_options_previously_deprecated(self, tmpdir, error_msg, config): | ||
# this test and related methods can be removed when no longer needed | ||
fake_env(tmpdir, config) | ||
with pytest.raises(InvalidConfigError, match=re.escape(error_msg)): | ||
get_dist(tmpdir).__enter__() | ||
|
||
|
||
class TestOptions: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this function out of the class to allow caching without memory leaks (otherwise it would keep a reference to
self
).