From b6acd3e68c9c6ccb05b9497d2d1cd5cec67892bd Mon Sep 17 00:00:00 2001 From: Tobias Nilsson Date: Sat, 22 Aug 2026 20:24:30 +0200 Subject: [PATCH 1/4] fix: rename publish skip hooks to check_skip_request --- src/python/pants/backend/docker/goals/publish.py | 2 +- src/python/pants/backend/helm/goals/publish.py | 2 +- src/python/pants/backend/python/goals/publish.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/python/pants/backend/docker/goals/publish.py b/src/python/pants/backend/docker/goals/publish.py index eeae6b6dbe1..0091a1e326f 100644 --- a/src/python/pants/backend/docker/goals/publish.py +++ b/src/python/pants/backend/docker/goals/publish.py @@ -53,7 +53,7 @@ class PublishDockerImageFieldSet(PublishFieldSet, DockerPackageFieldSet): skip_push: DockerImageSkipPushField - def make_skip_request( + def check_skip_request( self, package_fs: PackageFieldSet ) -> PublishDockerImageSkipRequest | None: return ( diff --git a/src/python/pants/backend/helm/goals/publish.py b/src/python/pants/backend/helm/goals/publish.py index ce76b3a1927..66abf9042f5 100644 --- a/src/python/pants/backend/helm/goals/publish.py +++ b/src/python/pants/backend/helm/goals/publish.py @@ -48,7 +48,7 @@ class HelmPublishFieldSet(HelmChartFieldSet, PublishFieldSet): repository: HelmChartRepositoryField skip_push: HelmSkipPushField - def make_skip_request(self, package_fs: PackageFieldSet) -> PublishHelmChartSkipRequest | None: + def check_skip_request(self, package_fs: PackageFieldSet) -> PublishHelmChartSkipRequest | None: return PublishHelmChartSkipRequest(publish_fs=self, package_fs=package_fs) def get_output_data(self) -> PublishOutputData: diff --git a/src/python/pants/backend/python/goals/publish.py b/src/python/pants/backend/python/goals/publish.py index e77e0fb3a1f..82f4c1bce20 100644 --- a/src/python/pants/backend/python/goals/publish.py +++ b/src/python/pants/backend/python/goals/publish.py @@ -76,7 +76,7 @@ class PublishPythonPackageFieldSet(PublishFieldSet): repositories: PythonRepositoriesField skip_twine: SkipTwineUploadField - def make_skip_request(self, package_fs: PackageFieldSet) -> PythonDistCheckSkipRequest | None: + def check_skip_request(self, package_fs: PackageFieldSet) -> PythonDistCheckSkipRequest | None: return PythonDistCheckSkipRequest(publish_fs=self, package_fs=package_fs) def get_output_data(self) -> PublishOutputData: From fe1cea6d12a25c487b1ed45eeb3d69a9d0ebbf0a Mon Sep 17 00:00:00 2001 From: Tobias Nilsson Date: Sat, 22 Aug 2026 20:27:57 +0200 Subject: [PATCH 2/4] fix: mark publish skip hooks with @override --- src/python/pants/backend/docker/goals/publish.py | 3 ++- src/python/pants/backend/helm/goals/publish.py | 2 ++ src/python/pants/backend/python/goals/publish.py | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/python/pants/backend/docker/goals/publish.py b/src/python/pants/backend/docker/goals/publish.py index 0091a1e326f..cf22a33261a 100644 --- a/src/python/pants/backend/docker/goals/publish.py +++ b/src/python/pants/backend/docker/goals/publish.py @@ -7,7 +7,7 @@ from collections import defaultdict from dataclasses import dataclass from itertools import chain -from typing import DefaultDict, cast +from typing import DefaultDict, cast, override from pants.backend.docker.goals.package_image import ( DockerPackageFieldSet, @@ -53,6 +53,7 @@ class PublishDockerImageFieldSet(PublishFieldSet, DockerPackageFieldSet): skip_push: DockerImageSkipPushField + @override def check_skip_request( self, package_fs: PackageFieldSet ) -> PublishDockerImageSkipRequest | None: diff --git a/src/python/pants/backend/helm/goals/publish.py b/src/python/pants/backend/helm/goals/publish.py index 66abf9042f5..5293919c5eb 100644 --- a/src/python/pants/backend/helm/goals/publish.py +++ b/src/python/pants/backend/helm/goals/publish.py @@ -6,6 +6,7 @@ import logging from collections.abc import Iterable from dataclasses import dataclass +from typing import override from pants.backend.helm.goals.package import BuiltHelmArtifact from pants.backend.helm.resolve.remotes import HelmRegistry @@ -48,6 +49,7 @@ class HelmPublishFieldSet(HelmChartFieldSet, PublishFieldSet): repository: HelmChartRepositoryField skip_push: HelmSkipPushField + @override def check_skip_request(self, package_fs: PackageFieldSet) -> PublishHelmChartSkipRequest | None: return PublishHelmChartSkipRequest(publish_fs=self, package_fs=package_fs) diff --git a/src/python/pants/backend/python/goals/publish.py b/src/python/pants/backend/python/goals/publish.py index 82f4c1bce20..cb27bca0c25 100644 --- a/src/python/pants/backend/python/goals/publish.py +++ b/src/python/pants/backend/python/goals/publish.py @@ -5,6 +5,7 @@ import logging from dataclasses import dataclass +from typing import override from pants.backend.python.subsystems.setuptools import PythonDistributionFieldSet from pants.backend.python.subsystems.twine import TwineSubsystem @@ -76,6 +77,7 @@ class PublishPythonPackageFieldSet(PublishFieldSet): repositories: PythonRepositoriesField skip_twine: SkipTwineUploadField + @override def check_skip_request(self, package_fs: PackageFieldSet) -> PythonDistCheckSkipRequest | None: return PythonDistCheckSkipRequest(publish_fs=self, package_fs=package_fs) From bce949ed2bbfa2967554c182526d23a7f9c3271f Mon Sep 17 00:00:00 2001 From: Tobias Nilsson Date: Sat, 22 Aug 2026 20:29:22 +0200 Subject: [PATCH 3/4] test: build publish skip requests via the hook --- src/python/pants/backend/docker/goals/publish_test.py | 7 +++---- src/python/pants/backend/helm/goals/publish_test.py | 7 +++---- src/python/pants/backend/python/goals/publish_test.py | 6 +++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/python/pants/backend/docker/goals/publish_test.py b/src/python/pants/backend/docker/goals/publish_test.py index b063fde3a56..f26f9d8ef33 100644 --- a/src/python/pants/backend/docker/goals/publish_test.py +++ b/src/python/pants/backend/docker/goals/publish_test.py @@ -331,12 +331,11 @@ def mock_get_image_refs(request: GetImageRefsRequest) -> DockerImageRefs: if image_refs else None ) + skip_request = publish_fs.check_skip_request(package_fs) + assert isinstance(skip_request, PublishDockerImageSkipRequest) result = run_rule_with_mocks( check_if_skip_push, - rule_args=[ - PublishDockerImageSkipRequest(publish_fs=publish_fs, package_fs=package_fs), - docker_options, - ], + rule_args=[skip_request, docker_options], mock_calls=mock_calls, ) assert result == expected diff --git a/src/python/pants/backend/helm/goals/publish_test.py b/src/python/pants/backend/helm/goals/publish_test.py index ebfe6dda237..3572e24a46c 100644 --- a/src/python/pants/backend/helm/goals/publish_test.py +++ b/src/python/pants/backend/helm/goals/publish_test.py @@ -209,12 +209,11 @@ def mock_get_helm_chart(request: HelmChartRequest) -> HelmChart: if artifact_name else None ) + skip_request = publish_fs.check_skip_request(package_fs) + assert isinstance(skip_request, PublishHelmChartSkipRequest) result = run_rule_with_mocks( check_if_skip_push, - rule_args=[ - PublishHelmChartSkipRequest(publish_fs=publish_fs, package_fs=package_fs), - helm_subsystem, - ], + rule_args=[skip_request, helm_subsystem], mock_calls=mock_calls, ) assert result == expected diff --git a/src/python/pants/backend/python/goals/publish_test.py b/src/python/pants/backend/python/goals/publish_test.py index 825148cd2ff..da7a7e02332 100644 --- a/src/python/pants/backend/python/goals/publish_test.py +++ b/src/python/pants/backend/python/goals/publish_test.py @@ -185,10 +185,10 @@ def test_check_if_skip_upload( rule_runner.set_options(["--twine-skip" if skip_twine_config else "--no-twine-skip"]) rule_runner.write_files(project_files(skip_twine=skip_twine, repositories=repositories)) tgt = rule_runner.get_target(Address("src", target_name="dist")) - request = PythonDistCheckSkipRequest( - publish_fs=PublishPythonPackageFieldSet.create(tgt), - package_fs=PythonDistributionFieldSet.create(tgt), + request = PublishPythonPackageFieldSet.create(tgt).check_skip_request( + PythonDistributionFieldSet.create(tgt) ) + assert isinstance(request, PythonDistCheckSkipRequest) result = rule_runner.request(CheckSkipResult, [request]) if expected: assert not result.skipped_packages From dbb8aa04732c220ddb694f7b63b500d496d8d283 Mon Sep 17 00:00:00 2001 From: Tobias Nilsson Date: Sat, 22 Aug 2026 20:31:44 +0200 Subject: [PATCH 4/4] docs: note the publish skip-field fix in 2.32.x --- docs/notes/2.32.x.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/notes/2.32.x.md b/docs/notes/2.32.x.md index eba0c97465d..1973d06b530 100644 --- a/docs/notes/2.32.x.md +++ b/docs/notes/2.32.x.md @@ -85,6 +85,8 @@ The `find-links` automatically injected by `pants.backend.plugin_development` is Fixed inverted logic when setting `noninteractive_process_output` to only log failures. +Fixed the `publish` goal ignoring `skip_push` on `docker_image` and `helm_chart` targets, `skip_twine` on `python_distribution` targets, and the `[twine].skip` option, all of which had no effect on targets matched by the command line ([#23621](https://github.com/pantsbuild/pants/issues/23621)). The preemptive skip check those fields moved into was never invoked, because each backend spelled the `PublishFieldSet` hook `make_skip_request` rather than `check_skip_request`. + ### Backends #### Docker