@@ -6,6 +6,13 @@ use itertools::Itertools;
6
6
use ruff_db:: files:: File ;
7
7
use ruff_python_ast as ast;
8
8
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;
9
16
use crate :: semantic_index:: ast_ids:: HasScopedAstId ;
10
17
use crate :: semantic_index:: definition:: Definition ;
11
18
use crate :: semantic_index:: symbol:: { self as symbol, ScopeId , ScopedSymbolId } ;
@@ -22,13 +29,6 @@ use crate::types::mro::{ClassBase, Mro, MroError, MroIterator};
22
29
use crate :: types:: narrow:: narrowing_constraint;
23
30
use crate :: { Db , FxOrderSet , Module , Program } ;
24
31
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
-
32
32
mod builder;
33
33
mod diagnostic;
34
34
mod display;
@@ -1720,7 +1720,7 @@ impl<'db> KnownClass {
1720
1720
}
1721
1721
}
1722
1722
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 > {
1724
1724
// Note: if this becomes hard to maintain (as rust can't ensure at compile time that all
1725
1725
// variants of `Self` are covered), we might use a macro (in-house or dependency)
1726
1726
// See: https://stackoverflow.com/q/39070244
@@ -1747,7 +1747,8 @@ impl<'db> KnownClass {
1747
1747
_ => return None ,
1748
1748
} ;
1749
1749
1750
- candidate. check_module ( module) . then_some ( candidate)
1750
+ let module = file_to_module ( db, file) ?;
1751
+ candidate. check_module ( & module) . then_some ( candidate)
1751
1752
}
1752
1753
1753
1754
/// Return `true` if the module of `self` matches `module_name`
0 commit comments