From e56603beb95f9bf510f3e94a2c2449cf1d9819ab Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Thu, 6 Jan 2022 19:53:59 -0700 Subject: [PATCH 1/2] Deprecate `[validate].detail_level` in favor of `[sourcefile-validation].detail_level` # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels] --- .../project_info/source_file_validator.py | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/python/pants/backend/project_info/source_file_validator.py b/src/python/pants/backend/project_info/source_file_validator.py index e8cd823cb9a..9fc0b908030 100644 --- a/src/python/pants/backend/project_info/source_file_validator.py +++ b/src/python/pants/backend/project_info/source_file_validator.py @@ -7,8 +7,9 @@ import textwrap from dataclasses import dataclass from enum import Enum -from typing import Any, cast +from typing import Any +from pants.base.deprecated import resolve_conflicting_options from pants.base.exiter import PANTS_FAILED_EXIT_CODE, PANTS_SUCCEEDED_EXIT_CODE from pants.engine.collection import Collection from pants.engine.console import Console @@ -49,12 +50,12 @@ def register_options(cls, register): type=DetailLevel, default=DetailLevel.nonmatching, help="How much detail to emit to the console.", + removal_version="2.11.0.dev0", + removal_hint=( + "Use `[sourcefile-validation].detail_level` instead, which behaves the same." + ), ) - @property - def detail_level(self) -> DetailLevel: - return cast(DetailLevel, self.options.detail_level) - class Validate(Goal): subsystem_cls = ValidateSubsystem @@ -131,11 +132,27 @@ def register_options(cls, register): ) super().register_options(register) register("--config", type=dict, fromfile=True, help=schema_help) + register( + "--detail-level", + type=DetailLevel, + default=DetailLevel.nonmatching, + help="How much detail to include in the result.", + ) @memoized_method def get_multi_matcher(self): return MultiMatcher(ValidationConfig.from_dict(self.options.config)) + def detail_level(self, validate_subsystem: ValidateSubsystem) -> DetailLevel: + return resolve_conflicting_options( + old_option="detail_level", + new_option="detail_level", + old_container=validate_subsystem.options, + new_container=self.options, + old_scope=validate_subsystem.name, + new_scope=self.options_scope, + ) + @dataclass(frozen=True) class RegexMatchResult: @@ -291,7 +308,7 @@ async def validate( for file_content in sorted(digest_contents, key=lambda fc: fc.path) ) - detail_level = validate_subsystem.detail_level + detail_level = source_file_validation.detail_level(validate_subsystem) num_matched_all = 0 num_nonmatched_some = 0 for rmr in regex_match_results: From 1e9866fc756fe69dc90a408137102ff02f194f95 Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Fri, 7 Jan 2022 09:14:22 -0700 Subject: [PATCH 2/2] Fix type hint # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels] --- .../project_info/source_file_validator.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/python/pants/backend/project_info/source_file_validator.py b/src/python/pants/backend/project_info/source_file_validator.py index 9fc0b908030..c6d98a2eea0 100644 --- a/src/python/pants/backend/project_info/source_file_validator.py +++ b/src/python/pants/backend/project_info/source_file_validator.py @@ -7,7 +7,7 @@ import textwrap from dataclasses import dataclass from enum import Enum -from typing import Any +from typing import Any, cast from pants.base.deprecated import resolve_conflicting_options from pants.base.exiter import PANTS_FAILED_EXIT_CODE, PANTS_SUCCEEDED_EXIT_CODE @@ -144,13 +144,16 @@ def get_multi_matcher(self): return MultiMatcher(ValidationConfig.from_dict(self.options.config)) def detail_level(self, validate_subsystem: ValidateSubsystem) -> DetailLevel: - return resolve_conflicting_options( - old_option="detail_level", - new_option="detail_level", - old_container=validate_subsystem.options, - new_container=self.options, - old_scope=validate_subsystem.name, - new_scope=self.options_scope, + return cast( + DetailLevel, + resolve_conflicting_options( + old_option="detail_level", + new_option="detail_level", + old_container=validate_subsystem.options, + new_container=self.options, + old_scope=validate_subsystem.name, + new_scope=self.options_scope, + ), )