File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -258,24 +258,20 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> None:
258258
259259
260260def scan_file_for_imports (file_path : str ) -> Set [str ]:
261- """Scan a Python file for external package imports.
262-
263- Excludes local modules (Python files in the same directory).
264- """
261+ """Scan a Python file for external package imports."""
265262 with open (file_path , "r" ) as f :
266263 code = f .read ()
267264 tree = ast .parse (code )
268265 visitor = ImportVisitor ()
269266 visitor .visit (tree )
270267
271- # Filter out local modules (files in the same directory)
268+ # Filter out local modules
272269 file_dir = os .path .dirname (file_path )
273270 filtered_imports = set ()
274271 for package in visitor .imports :
275- # Check if this is a local module (a .py file exists in the same directory)
272+ # Check if a .py file exists in the same directory
276273 local_module_path = os .path .join (file_dir , f"{ package } .py" )
277274 if not os .path .exists (local_module_path ):
278- # Not a local module, keep it in the imports
279275 filtered_imports .add (package )
280276
281277 return filtered_imports
You can’t perform that action at this time.
0 commit comments