Update options display

This commit is contained in:
Zanie
2023-10-25 17:56:42 -05:00
parent 9c63d80257
commit 8898906ef4
3 changed files with 24 additions and 21 deletions

View File

@@ -112,7 +112,7 @@ def summarize_check_result(result: Result) -> str:
markdown_project_section(
title=f"+{diff.lines_added}, -{diff.lines_removed}",
content=diff_lines,
options=project.check_options.markdown(),
options=project.check_options,
project=project,
)
)
@@ -122,7 +122,7 @@ def summarize_check_result(result: Result) -> str:
markdown_project_section(
title="error",
content=str(error),
options="",
options=project.check_options,
project=project,
)
)
@@ -146,7 +146,7 @@ def summarize_check_result(result: Result) -> str:
lines.extend(
markdown_details(
summary="Rule change summary",
preface="f"{len(all_rule_changes.rule_codes())} rules changed"",
preface=f"{len(all_rule_changes.rule_codes())} rules changed",
content=table_lines,
)
)
@@ -166,18 +166,10 @@ def add_permalink_to_diagnostic_line(repo: ClonedRepository, line: str) -> str:
async def ruff_check(
*, executable: Path, path: Path, name: str, options: CheckOptions
) -> Sequence[str]:
) -> tuple[str, Sequence[str]]:
"""Run the given ruff binary against the specified path."""
logger.debug(f"Checking {name} with {executable}")
ruff_args = ["check", "--no-cache", "--exit-zero"]
if options.select:
ruff_args.extend(["--select", options.select])
if options.ignore:
ruff_args.extend(["--ignore", options.ignore])
if options.exclude:
ruff_args.extend(["--exclude", options.exclude])
if options.show_fixes:
ruff_args.extend(["--show-fixes", "--ecosystem-ci"])
ruff_args = options.to_cli_args()
start = time.time()
proc = await create_subprocess_exec(
@@ -225,6 +217,18 @@ class CheckOptions(Serializable):
def markdown(self) -> str:
return f"select {self.select} ignore {self.ignore} exclude {self.exclude}"
def to_cli_args(self) -> list[str]:
args = ["check", "--no-cache", "--exit-zero"]
if self.select:
args.extend(["--select", self.select])
if self.ignore:
args.extend(["--ignore", self.ignore])
if self.exclude:
args.extend(["--exclude", self.exclude])
if self.show_fixes:
args.extend(["--show-fixes", "--ecosystem-ci"])
return args
@dataclass(frozen=True)
class RuleChanges:

View File

@@ -59,7 +59,7 @@ def summarize_format_result(result: Result) -> str:
markdown_project_section(
title=title,
content=patch_set_with_permalinks(patch_set, comparison.repo),
options=project.format_options.markdown(),
options=project.format_options,
project=project,
)
)
@@ -69,7 +69,7 @@ def summarize_format_result(result: Result) -> str:
markdown_project_section(
title="error",
content=str(error),
options="",
options=project.format_options,
project=project,
)
)
@@ -176,13 +176,12 @@ def create_format_comparison(repo: ClonedRepository, diff: str) -> FormatCompari
@dataclass(frozen=True)
class FormatOptions:
"""
Ruff format options
Ruff format options.
"""
pass
def markdown(self: Self) -> str:
return ""
def to_cli_args(self) -> list[str]:
args = ["format", "--diff"]
return args
@dataclass(frozen=True)

View File

@@ -11,7 +11,7 @@ def markdown_project_section(
) -> list[str]:
return markdown_details(
summary=f'<a href="{project.repo.url}">{project.repo.fullname}</a> ({title})',
preface=options,
preface="`ruff " + " ".join(options.to_cli_args()) + "`",
content=content,
)