Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions pyrefly/lib/commands/coverage/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ pub struct CheckArgs {
public_only: bool,

/// Format for the untyped-symbol findings.
#[arg(long, value_enum)]
output_format: Option<OutputFormat>,
#[arg(long, value_enum, default_value_t)]
output_format: OutputFormat,
}

impl CheckArgs {
Expand Down Expand Up @@ -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, &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(),
Expand Down
22 changes: 12 additions & 10 deletions website/docs/report.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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

Expand Down
Loading