diff --git a/check_dist/_core.py b/check_dist/_core.py index 04c000c..3679423 100644 --- a/check_dist/_core.py +++ b/check_dist/_core.py @@ -633,6 +633,10 @@ def check_sdist_vs_vcs( # Artifacts are built files not in VCS but expected in dists artifacts = hatch_config.get("artifacts", []) + # There are also artifact sections in sdist and wheel config that should be considered when comparing against VCS + sdist_artifacts = hatch_config.get("targets", {}).get("sdist", {}).get("artifacts", []) + artifacts.extend(sdist_artifacts) + # "Extra" = files in sdist that are neither VCS-tracked nor # generated artifacts. This catches truly stray files. extra = sorted(sdist_set - vcs_set) diff --git a/check_dist/tests/test_all.py b/check_dist/tests/test_all.py index 29c360e..5b5dd4c 100644 --- a/check_dist/tests/test_all.py +++ b/check_dist/tests/test_all.py @@ -328,6 +328,14 @@ def test_artifacts_not_flagged_as_extra(self): errors = check_sdist_vs_vcs(sdist, vcs, hatch) assert errors == [] + def test_artifacts_in_sdist_section(self): + """Artifacts listed in hatch sdist config should also be ignored.""" + sdist = ["pkg/extension/index.js", "pkg/__init__.py", "pyproject.toml"] + vcs = ["pkg/__init__.py", "pyproject.toml"] + hatch = {"targets": {"sdist": {"artifacts": ["pkg/extension"]}}} + errors = check_sdist_vs_vcs(sdist, vcs, hatch) + assert errors == [] + def test_only_include_vcs_check(self): """only-include config should scope the VCS comparison.""" sdist = ["pkg/__init__.py", "rust/lib.rs", "Cargo.toml", "pyproject.toml"]