Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate [validate].detail_level in favor of [sourcefile-validation].detail_level #14103

Merged
Merged
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
30 changes: 25 additions & 5 deletions src/python/pants/backend/project_info/source_file_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from enum import Enum
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
from pants.engine.collection import Collection
from pants.engine.console import Console
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -131,11 +132,30 @@ 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 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,
),
)


@dataclass(frozen=True)
class RegexMatchResult:
Expand Down Expand Up @@ -291,7 +311,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:
Expand Down