[ty] Change frequency of invalid `__all__` debug message

This was being emitted for every symbol we checked, which
is clearly too frequent. This switches to emitting it once
per module.
This commit is contained in:
Andrew Gallant 2025-12-10 14:25:45 -05:00 committed by Andrew Gallant
parent ff0ed4e752
commit a2b138e789
1 changed files with 10 additions and 8 deletions

View File

@ -470,6 +470,11 @@ impl<'db> SymbolVisitor<'db> {
} }
fn into_flat_symbols(mut self) -> FlatSymbols { fn into_flat_symbols(mut self) -> FlatSymbols {
// If `__all__` was found but wasn't recognized,
// then we emit a diagnostic message indicating as such.
if self.all_invalid {
tracing::debug!("Invalid `__all__` in `{}`", self.file.path(self.db));
}
// We want to filter out some of the symbols we collected. // We want to filter out some of the symbols we collected.
// Specifically, to respect conventions around library // Specifically, to respect conventions around library
// interface. // interface.
@ -810,14 +815,11 @@ impl<'db> SymbolVisitor<'db> {
// if a name should be part of the exported API of a module // if a name should be part of the exported API of a module
// or not. When there is `__all__`, we currently follow it // or not. When there is `__all__`, we currently follow it
// strictly. // strictly.
if self.all_origin.is_some() { //
// If `__all__` is somehow invalid, ignore it and fall // If `__all__` is somehow invalid, ignore it and fall
// through as-if `__all__` didn't exist. // through as-if `__all__` didn't exist.
if self.all_invalid { if self.all_origin.is_some() && !self.all_invalid {
tracing::debug!("Invalid `__all__` in `{}`", self.file.path(self.db)); return self.all_names.contains(&*symbol.name);
} else {
return self.all_names.contains(&*symbol.name);
}
} }
// "Imported symbols are considered private by default. A fixed // "Imported symbols are considered private by default. A fixed