@@ -11,7 +11,7 @@ use ruff_linter::package::PackageRoot;
1111use ruff_linter:: source_kind:: SourceKind ;
1212use ruff_linter:: { warn_user, warn_user_once} ;
1313use ruff_python_ast:: SourceType ;
14- use ruff_workspace:: resolver:: { ResolvedFile , match_exclusion, python_files_in_path } ;
14+ use ruff_workspace:: resolver:: { ResolvedFile , match_exclusion, project_files_in_path } ;
1515use rustc_hash:: { FxBuildHasher , FxHashMap } ;
1616use std:: io:: Write ;
1717use std:: path:: { Path , PathBuf } ;
@@ -35,7 +35,16 @@ pub(crate) fn analyze_graph(
3535
3636 // Find all Python files.
3737 let files = resolve_default_files ( args. files , false ) ;
38- let ( paths, resolver) = python_files_in_path ( & files, & pyproject_config, config_arguments) ?;
38+ let ( mut paths, resolver) = project_files_in_path ( & files, & pyproject_config, config_arguments) ?;
39+
40+ // Filter to only Python files
41+ paths. retain ( |path| {
42+ if let Ok ( ResolvedFile :: Root ( path) | ResolvedFile :: Nested ( path) ) = path {
43+ matches ! ( SourceType :: from( path) , SourceType :: Python ( _) )
44+ } else {
45+ true
46+ }
47+ } ) ;
3948
4049 if paths. is_empty ( ) {
4150 warn_user_once ! ( "No Python files found under the given path(s)" ) ;
@@ -124,6 +133,7 @@ pub(crate) fn analyze_graph(
124133 let string_imports = settings. analyze . string_imports ;
125134 let include_dependencies = settings. analyze . include_dependencies . get ( path) . cloned ( ) ;
126135 let type_checking_imports = settings. analyze . type_checking_imports ;
136+ let source_type = settings. analyze . extension . get_source_type ( path) ;
127137
128138 // Skip excluded files.
129139 if ( settings. file_resolver . force_exclude || !resolved_file. is_root ( ) )
@@ -136,19 +146,6 @@ pub(crate) fn analyze_graph(
136146 continue ;
137147 }
138148
139- // Ignore non-Python files.
140- let source_type = match settings. analyze . extension . get_source_type ( path) {
141- SourceType :: Python ( source_type) => source_type,
142- SourceType :: Toml ( _) => {
143- debug ! ( "Ignoring TOML file: {}" , path. display( ) ) ;
144- continue ;
145- }
146- SourceType :: Markdown => {
147- debug ! ( "Ignoring Markdown file: {}" , path. display( ) ) ;
148- continue ;
149- }
150- } ;
151-
152149 // Convert to system paths.
153150 let Ok ( package) = package. map ( SystemPathBuf :: from_path_buf) . transpose ( ) else {
154151 warn ! ( "Failed to convert package to system path" ) ;
@@ -165,10 +162,7 @@ pub(crate) fn analyze_graph(
165162 let result = inner_result. clone ( ) ;
166163 scope. spawn ( move |_| {
167164 // Extract source code (handles both .py and .ipynb files)
168- let source_kind = match SourceKind :: from_path (
169- path. as_std_path ( ) ,
170- SourceType :: Python ( source_type) ,
171- ) {
165+ let source_kind = match SourceKind :: from_path ( path. as_std_path ( ) , source_type) {
172166 Ok ( Some ( source_kind) ) => source_kind,
173167 Ok ( None ) => {
174168 debug ! ( "Skipping non-Python notebook: {path}" ) ;
@@ -186,7 +180,7 @@ pub(crate) fn analyze_graph(
186180 let mut imports = ModuleImports :: detect (
187181 & db,
188182 source_code,
189- source_type,
183+ source_type. expect_python ( ) ,
190184 & path,
191185 package. as_deref ( ) ,
192186 string_imports,
0 commit comments