From 3369851ee3ffeb81c57074bef3900bac3bf2b364 Mon Sep 17 00:00:00 2001 From: jorenham Date: Wed, 15 Jul 2026 19:49:45 +0200 Subject: [PATCH 1/2] Always print coverage findings in `pyrefly coverage check --fail-under=` --- pyrefly/lib/commands/coverage/check.rs | 5 +++-- website/docs/report.mdx | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/pyrefly/lib/commands/coverage/check.rs b/pyrefly/lib/commands/coverage/check.rs index 6ee4abe94e..ad3ae5a94e 100644 --- a/pyrefly/lib/commands/coverage/check.rs +++ b/pyrefly/lib/commands/coverage/check.rs @@ -100,12 +100,13 @@ impl CheckArgs { number_thousands(total.n_typable), ); + let root = std::env::current_dir().unwrap_or_default(); + write_errors_to_console(self.output_format.unwrap_or_default(), &root, &errors)?; + if coverage + 1e-9 >= self.fail_under { eprintln!("{} {summary}", Severity::Info.painted()); Ok(CommandExitStatus::Success) } else { - let root = std::env::current_dir().unwrap_or_default(); - write_errors_to_console(self.output_format.unwrap_or_default(), &root, &errors)?; eprintln!( "{} {summary} is below the {:.2}% threshold", Severity::Error.painted(), diff --git a/website/docs/report.mdx b/website/docs/report.mdx index ee1d4304c5..90fa949df5 100644 --- a/website/docs/report.mdx +++ b/website/docs/report.mdx @@ -45,14 +45,8 @@ reachable from public modules via re-export chains count: the library's public A pyrefly coverage check robot/ --fail-under 60 ``` -On success it prints a one-line summary and exits 0: - -``` - INFO type coverage 66.67% (4 of 6 typable) -``` - -Otherwise it exits non-zero and reports every offending symbol in the same style as -`pyrefly check`, as `coverage-missing` (no annotations at all) or `coverage-partial` (only some): +It reports every offending symbol in the same style as `pyrefly check`, as `coverage-missing` +(no annotations at all) or `coverage-partial` (only some), followed by a one-line summary: ``` WARN `walk` is not fully typed [coverage-partial] @@ -72,8 +66,16 @@ Otherwise it exits non-zero and reports every offending symbol in the same style ERROR type coverage 66.67% (4 of 6 typable) is below the 100.00% threshold ``` -With `--strict`, annotations that resolve to `Any` count as untyped. The findings format is -configurable with `--output-format`. See `pyrefly coverage check --help` for all flags. +When coverage meets the threshold, the findings are printed but the summary is INFO and the exit +code is 0: + +``` + INFO type coverage 66.67% (4 of 6 typable) +``` + +Findings go to stdout, the summary to stderr. With `--strict`, annotations that resolve to `Any` +count as untyped. `--output-format` controls the findings format. +See `pyrefly coverage check --help` for all flags. ## Generating a JSON report From f82fc91f6a4564f8ca38c3f6a65d2e776bd57e2e Mon Sep 17 00:00:00 2001 From: jorenham Date: Wed, 15 Jul 2026 19:50:32 +0200 Subject: [PATCH 2/2] Simplify console printing code in `pyrefly coverage check` --- pyrefly/lib/commands/coverage/check.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyrefly/lib/commands/coverage/check.rs b/pyrefly/lib/commands/coverage/check.rs index ad3ae5a94e..32001fe305 100644 --- a/pyrefly/lib/commands/coverage/check.rs +++ b/pyrefly/lib/commands/coverage/check.rs @@ -48,8 +48,8 @@ pub struct CheckArgs { public_only: bool, /// Format for the untyped-symbol findings. - #[arg(long, value_enum)] - output_format: Option, + #[arg(long, value_enum, default_value_t)] + output_format: OutputFormat, } impl CheckArgs { @@ -101,7 +101,7 @@ impl CheckArgs { ); let root = std::env::current_dir().unwrap_or_default(); - write_errors_to_console(self.output_format.unwrap_or_default(), &root, &errors)?; + write_errors_to_console(self.output_format, &root, &errors)?; if coverage + 1e-9 >= self.fail_under { eprintln!("{} {summary}", Severity::Info.painted());