mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-17 13:57:25 +00:00
[ty] Log files that are slow to type check (#20836)
This commit is contained in:
parent
350042b801
commit
c80ee1a50b
1 changed files with 13 additions and 1 deletions
|
@ -3,6 +3,7 @@ use itertools::{Either, Itertools};
|
|||
use ruff_db::parsed::parsed_module;
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::time::Duration;
|
||||
|
||||
use bitflags::bitflags;
|
||||
use call::{CallDunderError, CallError, CallErrorKind};
|
||||
|
@ -11,11 +12,13 @@ use diagnostic::{
|
|||
INVALID_CONTEXT_MANAGER, INVALID_SUPER_ARGUMENT, NOT_ITERABLE, POSSIBLY_MISSING_IMPLICIT_CALL,
|
||||
UNAVAILABLE_IMPLICIT_SUPER_ARGUMENTS,
|
||||
};
|
||||
use ruff_db::Instant;
|
||||
use ruff_db::diagnostic::{Annotation, Diagnostic, Span, SubDiagnostic, SubDiagnosticSeverity};
|
||||
use ruff_db::files::File;
|
||||
use ruff_python_ast::name::Name;
|
||||
use ruff_python_ast::{self as ast, AnyNodeRef};
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
use type_ordering::union_or_intersection_elements_ordering;
|
||||
|
||||
pub(crate) use self::builder::{IntersectionBuilder, UnionBuilder};
|
||||
|
@ -106,9 +109,10 @@ mod property_tests;
|
|||
|
||||
pub fn check_types(db: &dyn Db, file: File) -> Vec<Diagnostic> {
|
||||
let _span = tracing::trace_span!("check_types", ?file).entered();
|
||||
|
||||
tracing::debug!("Checking file '{path}'", path = file.path(db));
|
||||
|
||||
let start = Instant::now();
|
||||
|
||||
let index = semantic_index(db, file);
|
||||
let mut diagnostics = TypeCheckDiagnostics::default();
|
||||
|
||||
|
@ -129,6 +133,14 @@ pub fn check_types(db: &dyn Db, file: File) -> Vec<Diagnostic> {
|
|||
|
||||
check_suppressions(db, file, &mut diagnostics);
|
||||
|
||||
let elapsed = start.elapsed();
|
||||
if elapsed >= Duration::from_millis(100) {
|
||||
tracing::info!(
|
||||
"Checking file `{path}` took more than 100ms ({elapsed:?})",
|
||||
path = file.path(db)
|
||||
);
|
||||
}
|
||||
|
||||
diagnostics.into_diagnostics()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue