Skip to content

Commit 59b1221

Browse files
committed
.
1 parent bb12b0d commit 59b1221

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

crates/ty_python_semantic/src/module_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl ModuleName {
318318
db: &dyn Db,
319319
importing_file: File,
320320
) -> Result<Self, ModuleNameResolutionError> {
321-
relative_module_name(db, importing_file, None, NonZeroU32::new(1).unwrap())
321+
Self::from_identifier_parts(db, importing_file, None, 1)
322322
}
323323
}
324324

crates/ty_python_semantic/src/semantic_index/builder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,11 +1551,11 @@ impl<'ast> Visitor<'ast> for SemanticIndexBuilder<'_, 'ast> {
15511551
);
15521552
}
15531553
} else {
1554-
self.imported_modules.extend(
1555-
module_name
1556-
.ancestors()
1557-
.zip(std::iter::repeat(ImportKind::ImportFrom)),
1558-
);
1554+
for name in module_name.ancestors() {
1555+
self.imported_modules
1556+
.entry(name)
1557+
.or_insert(ImportKind::ImportFrom);
1558+
}
15591559
}
15601560
}
15611561
}

crates/ty_python_semantic/src/types.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11724,13 +11724,9 @@ impl<'db> ModuleLiteralType<'db> {
1172411724
.into_iter()
1172511725
.flat_map(|file| imported_modules(db, file))
1172611726
.filter_map(|(submodule_name, kind)| {
11727-
Some((submodule_name.relative_to(self.module(db).name(db))?, kind))
11728-
})
11729-
.filter_map(|(relative_submodule, kind)| {
11730-
relative_submodule
11731-
.components()
11732-
.next()
11733-
.map(|module| (Name::from(module), *kind))
11727+
let relative_name = submodule_name.relative_to(self.module(db).name(db))?;
11728+
let available_attribute = relative_name.components().next()?;
11729+
Some((Name::from(available_attribute), *kind))
1173411730
})
1173511731
}
1173611732

0 commit comments

Comments
 (0)