@@ -6,6 +6,13 @@ use itertools::Itertools;
66use ruff_db:: files:: File ;
77use ruff_python_ast as ast;
88
9+ pub ( crate ) use self :: builder:: { IntersectionBuilder , UnionBuilder } ;
10+ pub use self :: diagnostic:: { TypeCheckDiagnostic , TypeCheckDiagnostics } ;
11+ pub ( crate ) use self :: display:: TypeArrayDisplay ;
12+ pub ( crate ) use self :: infer:: {
13+ infer_deferred_types, infer_definition_types, infer_expression_types, infer_scope_types,
14+ } ;
15+ use crate :: module_resolver:: file_to_module;
916use crate :: semantic_index:: ast_ids:: HasScopedAstId ;
1017use crate :: semantic_index:: definition:: Definition ;
1118use crate :: semantic_index:: symbol:: { self as symbol, ScopeId , ScopedSymbolId } ;
@@ -22,13 +29,6 @@ use crate::types::mro::{ClassBase, Mro, MroError, MroIterator};
2229use crate :: types:: narrow:: narrowing_constraint;
2330use crate :: { Db , FxOrderSet , Module , Program } ;
2431
25- pub ( crate ) use self :: builder:: { IntersectionBuilder , UnionBuilder } ;
26- pub use self :: diagnostic:: { TypeCheckDiagnostic , TypeCheckDiagnostics } ;
27- pub ( crate ) use self :: display:: TypeArrayDisplay ;
28- pub ( crate ) use self :: infer:: {
29- infer_deferred_types, infer_definition_types, infer_expression_types, infer_scope_types,
30- } ;
31-
3232mod builder;
3333mod diagnostic;
3434mod display;
@@ -1720,7 +1720,7 @@ impl<'db> KnownClass {
17201720 }
17211721 }
17221722
1723- pub fn try_from_module ( module : & Module , class_name : & str ) -> Option < Self > {
1723+ pub fn try_from_file ( db : & dyn Db , file : File , class_name : & str ) -> Option < Self > {
17241724 // Note: if this becomes hard to maintain (as rust can't ensure at compile time that all
17251725 // variants of `Self` are covered), we might use a macro (in-house or dependency)
17261726 // See: https://stackoverflow.com/q/39070244
@@ -1747,7 +1747,8 @@ impl<'db> KnownClass {
17471747 _ => return None ,
17481748 } ;
17491749
1750- candidate. check_module ( module) . then_some ( candidate)
1750+ let module = file_to_module ( db, file) ?;
1751+ candidate. check_module ( & module) . then_some ( candidate)
17511752 }
17521753
17531754 /// Return `true` if the module of `self` matches `module_name`
0 commit comments