mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 21:35:58 +00:00
[red-knot] Fallback to attributes on types.ModuleType if a symbol can't be found in locals or globals (#13904)
This commit is contained in:
parent
7dd0c7f4bd
commit
d2c9f5e43c
5 changed files with 278 additions and 13 deletions
|
@ -195,6 +195,10 @@ impl<'db> SemanticIndexBuilder<'db> {
|
|||
self.current_symbol_table().mark_symbol_bound(id);
|
||||
}
|
||||
|
||||
fn mark_symbol_declared(&mut self, id: ScopedSymbolId) {
|
||||
self.current_symbol_table().mark_symbol_declared(id);
|
||||
}
|
||||
|
||||
fn mark_symbol_used(&mut self, id: ScopedSymbolId) {
|
||||
self.current_symbol_table().mark_symbol_used(id);
|
||||
}
|
||||
|
@ -226,6 +230,9 @@ impl<'db> SemanticIndexBuilder<'db> {
|
|||
if category.is_binding() {
|
||||
self.mark_symbol_bound(symbol);
|
||||
}
|
||||
if category.is_declaration() {
|
||||
self.mark_symbol_declared(symbol);
|
||||
}
|
||||
|
||||
let use_def = self.current_use_def_map_mut();
|
||||
match category {
|
||||
|
@ -359,6 +366,7 @@ impl<'db> SemanticIndexBuilder<'db> {
|
|||
// note that the "bound" on the typevar is a totally different thing than whether
|
||||
// or not a name is "bound" by a typevar declaration; the latter is always true.
|
||||
self.mark_symbol_bound(symbol);
|
||||
self.mark_symbol_declared(symbol);
|
||||
if let Some(bounds) = bound {
|
||||
self.visit_expr(bounds);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue