@@ -10,7 +10,7 @@ use ruff_db::source::{source_text, SourceText};
1010use ruff_index:: IndexVec ;
1111use ruff_python_ast:: name:: Name ;
1212use ruff_python_ast:: visitor:: { walk_expr, walk_pattern, walk_stmt, Visitor } ;
13- use ruff_python_ast:: { self as ast, PythonVersion } ;
13+ use ruff_python_ast:: { self as ast, PySourceType , PythonVersion } ;
1414use ruff_python_parser:: semantic_errors:: {
1515 SemanticSyntaxChecker , SemanticSyntaxContext , SemanticSyntaxError ,
1616} ;
@@ -75,6 +75,7 @@ pub(super) struct SemanticIndexBuilder<'db> {
7575 // Builder state
7676 db : & ' db dyn Db ,
7777 file : File ,
78+ source_type : PySourceType ,
7879 module : & ' db ParsedModule ,
7980 scope_stack : Vec < ScopeInfo > ,
8081 /// The assignments we're currently visiting, with
@@ -118,6 +119,7 @@ impl<'db> SemanticIndexBuilder<'db> {
118119 let mut builder = Self {
119120 db,
120121 file,
122+ source_type : file. source_type ( db. upcast ( ) ) ,
121123 module : parsed,
122124 scope_stack : Vec :: new ( ) ,
123125 current_assignments : vec ! [ ] ,
@@ -445,7 +447,7 @@ impl<'db> SemanticIndexBuilder<'db> {
445447 #[ allow( unsafe_code) ]
446448 // SAFETY: `definition_node` is guaranteed to be a child of `self.module`
447449 let kind = unsafe { definition_node. into_owned ( self . module . clone ( ) ) } ;
448- let category = kind. category ( self . file . is_stub ( self . db . upcast ( ) ) ) ;
450+ let category = kind. category ( self . source_type . is_stub ( ) ) ;
449451 let is_reexported = kind. is_reexported ( ) ;
450452
451453 let definition = Definition :: new (
0 commit comments