Skip to content

Commit 6a80618

Browse files
committed
Use module_ty for self-referential check
1 parent 91aa75a commit 6a80618

File tree

1 file changed

+3
-2
lines changed
  • crates/ty_python_semantic/src/types

1 file changed

+3
-2
lines changed

crates/ty_python_semantic/src/types/infer.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3948,8 +3948,9 @@ impl<'db> TypeInferenceBuilder<'db> {
39483948

39493949
// Avoid looking up attributes on a module if a module imports from itself
39503950
// (e.g. `from parent import submodule` inside the `parent` module).
3951-
let import_is_self_referential =
3952-
file_to_module(self.db(), self.file()).is_some_and(|m| m.name() == &module_name);
3951+
let import_is_self_referential = module_ty
3952+
.into_module_literal()
3953+
.is_some_and(|module| self.file() == module.module(self.db()).file());
39533954

39543955
// First try loading the requested attribute from the module.
39553956
if !import_is_self_referential {

0 commit comments

Comments
 (0)