Skip to content
Draft
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
5 changes: 4 additions & 1 deletion pyproject_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,10 @@ def from_pyproject( # noqa: C901
dynamic = pyproject.get_dynamic(project)

for field in dynamic:
if field in data["project"]:
if (
field in data["project"]
and field not in constants.PROJECT_DYNAMIC_STATIC
):
msg = 'Field {key} declared as dynamic in "project.dynamic" but is defined'
pyproject.config_error(msg, key=f"project.{field}")

Expand Down
17 changes: 17 additions & 0 deletions pyproject_metadata/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"KNOWN_PROJECT_FIELDS",
"KNOWN_TOPLEVEL_FIELDS",
"PRE_SPDX_METADATA_VERSIONS",
"PROJECT_DYNAMIC_STATIC",
"PROJECT_TO_METADATA",
]

Expand Down Expand Up @@ -48,6 +49,22 @@ def __dir__() -> list[str]:
"version": frozenset(["Version"]),
}

PROJECT_DYNAMIC_STATIC = {
"authors",
"classifiers",
"dependencies",
"keywords",
"license-files",
"maintainers",
"urls",
"entry-points",
"gui-scripts",
"optional-dependencies",
"scripts",
"license",
}


KNOWN_TOPLEVEL_FIELDS = {"build-system", "project", "tool", "dependency-groups"}
KNOWN_BUILD_SYSTEM_FIELDS = {"backend-path", "build-backend", "requires"}
KNOWN_PROJECT_FIELDS = set(PROJECT_TO_METADATA)
Expand Down
15 changes: 15 additions & 0 deletions tests/test_standard_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,21 @@ def test_statically_defined_dynamic_field() -> None:
)


def test_dual_defined_dynamic_field() -> None:
metadata = pyproject_metadata.StandardMetadata.from_pyproject(
{
"project": {
"name": "example",
"version": "1.2.3",
"dependencies": ["example"],
"dynamic": ["dependencies"],
},
}
)
assert len(metadata.dependencies) == 1
assert metadata.dynamic == ["dependencies"]


@pytest.mark.parametrize(
"value",
[
Expand Down
Loading