From 64f35f051a26631fdce0437099d86e1ca524e19d Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 7 Mar 2023 18:18:34 +0000 Subject: [PATCH] Minor adjustments in apply_pyproject.toml --- setuptools/config/_apply_pyprojecttoml.py | 6 +++--- setuptools/tests/config/test_apply_pyprojecttoml.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/setuptools/config/_apply_pyprojecttoml.py b/setuptools/config/_apply_pyprojecttoml.py index 3091e3b5e3..cdd65c821c 100644 --- a/setuptools/config/_apply_pyprojecttoml.py +++ b/setuptools/config/_apply_pyprojecttoml.py @@ -205,7 +205,7 @@ def _dependencies(dist: "Distribution", val: list, _root_dir): def _optional_dependencies(dist: "Distribution", val: dict, _root_dir): - existing = getattr(dist, "extras_require", {}) + existing = getattr(dist, "extras_require", None) or {} _set_config(dist, "extras_require", {**existing, **val}) @@ -353,8 +353,8 @@ def _acessor(obj): "classifiers": _attrgetter("metadata.classifiers"), "urls": _attrgetter("metadata.project_urls"), "entry-points": _get_previous_entrypoints, - "dependencies": _some_attrgetter("_orig_install_requires", "install_requires"), - "optional-dependencies": _some_attrgetter("_orig_extras_require", "extras_require"), + "dependencies": _attrgetter("install_requires"), + "optional-dependencies": _attrgetter("extras_require"), } diff --git a/setuptools/tests/config/test_apply_pyprojecttoml.py b/setuptools/tests/config/test_apply_pyprojecttoml.py index c9c521be16..b08f416460 100644 --- a/setuptools/tests/config/test_apply_pyprojecttoml.py +++ b/setuptools/tests/config/test_apply_pyprojecttoml.py @@ -379,12 +379,12 @@ def test_optional_dependencies_dont_remove_env_markers(self, tmp_path): dist = makedist(tmp_path, install_requires=install_req) dist = pyprojecttoml.apply_configuration(dist, pyproject) assert "foo" in dist.extras_require - assert ':python_version < "3.7"' in dist.extras_require egg_info = dist.get_command_obj("egg_info") write_requirements(egg_info, tmp_path, tmp_path / "requires.txt") reqs = (tmp_path / "requires.txt").read_text(encoding="utf-8") assert "importlib-resources" in reqs assert "bar" in reqs + assert ':python_version < "3.7"' in reqs @pytest.mark.parametrize( "field,group",