Skip to content

Commit

Permalink
Fix --process-cleanup deprecation. (#16447)
Browse files Browse the repository at this point in the history
The deprecation added in #16415 never displayed and the conversion from
the old `--process-cleanup` to the new `--keep-sandboxes` was inverted.
  • Loading branch information
jsirois authored Aug 8, 2022
1 parent a0e1b28 commit 1453e4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
12 changes: 0 additions & 12 deletions src/python/pants/engine/internals/options_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@

from dataclasses import dataclass

from pants.base.deprecated import warn_or_error
from pants.build_graph.build_configuration import BuildConfiguration
from pants.engine.internals.session import SessionValues
from pants.engine.rules import collect_rules, rule
from pants.option.global_options import (
GlobalOptions,
KeepSandboxes,
NamedCachesDirOption,
ProcessCleanupOption,
UseDeprecatedPexBinaryRunSemanticsOption,
)
from pants.option.options import Options
Expand Down Expand Up @@ -60,16 +58,6 @@ def log_level(global_options: GlobalOptions) -> LogLevel:
return global_options.level


@rule
def extract_process_cleanup_option(keep_sandboxes: KeepSandboxes) -> ProcessCleanupOption:
warn_or_error(
removal_version="2.15.0.dev1",
entity="ProcessCleanupOption",
hint="Instead, use `KeepSandboxes`.",
)
return ProcessCleanupOption(keep_sandboxes == KeepSandboxes.never)


@rule
def extract_keep_sandboxes(global_options: GlobalOptions) -> KeepSandboxes:
return GlobalOptions.resolve_keep_sandboxes(global_options.options)
Expand Down
19 changes: 7 additions & 12 deletions src/python/pants/option/global_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
is_in_container,
pants_version,
)
from pants.base.deprecated import deprecated_conditional, resolve_conflicting_options
from pants.base.deprecated import deprecated_conditional, resolve_conflicting_options, warn_or_error
from pants.base.glob_match_error_behavior import GlobMatchErrorBehavior
from pants.engine.environment import CompleteEnvironment
from pants.engine.internals.native_engine import PyExecutor
Expand Down Expand Up @@ -1935,7 +1935,12 @@ def resolve_keep_sandboxes(

if isinstance(resolved_value, bool):
# Is `process_cleanup`.
return KeepSandboxes.always if resolved_value else KeepSandboxes.on_failure
warn_or_error(
removal_version="2.15.0.dev1",
entity="--process-cleanup",
hint="Instead, use `--keep-sandboxes`.",
)
return KeepSandboxes.never if resolved_value else KeepSandboxes.always
elif isinstance(resolved_value, KeepSandboxes):
return resolved_value
else:
Expand Down Expand Up @@ -2033,16 +2038,6 @@ def create(cls, GlobalOptionsType: type[GlobalOptions]) -> GlobalOptionsFlags:
return cls(FrozenOrderedSet(flags), FrozenOrderedSet(short_flags))


@dataclass(frozen=True)
class ProcessCleanupOption:
"""A wrapper around the global option `process_cleanup`.
Prefer to use this rather than requesting `GlobalOptions` for more precise invalidation.
"""

val: bool


@dataclass(frozen=True)
class NamedCachesDirOption:
"""A wrapper around the global option `named_caches_dir`.
Expand Down

0 comments on commit 1453e4c

Please sign in to comment.