Skip to content

Commit 67e54ff

Browse files
authored
[ty] Fix panic for cyclic star imports (#21428)
1 parent a01b0d7 commit 67e54ff

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

crates/ty_python_semantic/src/semantic_index/re_exports.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ pub(super) fn exported_names(db: &dyn Db, file: File) -> Box<[Name]> {
3939
let module = parsed_module(db, file).load(db);
4040
let mut finder = ExportFinder::new(db, file);
4141
finder.visit_body(module.suite());
42-
finder.resolve_exports()
42+
43+
let mut exports = finder.resolve_exports();
44+
45+
// Sort the exports to ensure convergence regardless of hash map
46+
// or insertion order. See <https://github.com/astral-sh/ty/issues/444>
47+
exports.sort_unstable();
48+
exports.into()
4349
}
4450

4551
struct ExportFinder<'db> {
@@ -69,7 +75,7 @@ impl<'db> ExportFinder<'db> {
6975
}
7076
}
7177

72-
fn resolve_exports(self) -> Box<[Name]> {
78+
fn resolve_exports(self) -> Vec<Name> {
7379
match self.dunder_all {
7480
DunderAll::NotPresent => self
7581
.exports

0 commit comments

Comments
 (0)