Add progress bar for ty check (#17965)

## Summary

Adds a simple progress bar for the `ty check` CLI command. The style is
taken from uv, and like uv the bar is always shown - for smaller
projects it is fast enough that it isn't noticeable. We could
alternatively hide it completely based on some heuristic for the number
of files, or only show it after some amount of time.

I also disabled it when `--watch` is passed, cancelling inflight checks
was leading to zombie progress bars. I think we can fix this by using
[`MultiProgress`](https://docs.rs/indicatif/latest/indicatif/struct.MultiProgress.html)
and managing all the bars globally, but I left that out for now.

Resolves https://github.com/astral-sh/ty/issues/98.
This commit is contained in:
Ibraheem Ahmed 2025-05-09 13:32:27 -04:00 committed by GitHub
parent 25e13debc0
commit e9da1750a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 103 additions and 35 deletions

View file

@ -18,8 +18,8 @@ use ty_ide::{goto_type_definition, hover, inlay_hints, MarkupKind};
use ty_project::metadata::options::Options;
use ty_project::metadata::value::ValueSource;
use ty_project::watch::{ChangeEvent, ChangedKind, CreatedKind, DeletedKind};
use ty_project::ProjectMetadata;
use ty_project::{Db, ProjectDatabase};
use ty_project::{DummyReporter, ProjectMetadata};
use ty_python_semantic::Program;
use wasm_bindgen::prelude::*;
@ -186,7 +186,7 @@ impl Workspace {
/// Checks all open files
pub fn check(&self) -> Result<Vec<Diagnostic>, Error> {
let result = self.db.check().map_err(into_error)?;
let result = self.db.check(&DummyReporter).map_err(into_error)?;
Ok(result.into_iter().map(Diagnostic::wrap).collect())
}