Skip to content

Uniformize import matching analysis#255

Open
thomas-chauchefoin-tob wants to merge 4 commits intomasterfrom
uniformize-import-matching-analysis
Open

Uniformize import matching analysis#255
thomas-chauchefoin-tob wants to merge 4 commits intomasterfrom
uniformize-import-matching-analysis

Conversation

@thomas-chauchefoin-tob
Copy link
Collaborator

Fixed a few crashes and inconsistencies in import analysis:

  • Fix is_std_module() to handle dotted imports (os.path, collections.abc), and reduce false positives in NonStandardImports
  • Fix UnsafeImportsML and UnsafeImports to handle ast.Import nodes generated by Ext opcodes
  • Refactor UnsafeImportsML.analyze() for uniform extraction of module names from both ast.ImportFrom and ast.Import nodes
  • Fix eval import check that was skipped when the module was in UNSAFE_IMPORTS

thomas-chauchefoin-tob and others added 4 commits March 20, 2026 11:13
sys.stdlib_module_names only contains top-level names, so
is_std_module("os.path") incorrectly returned False. This caused
NonStandardImports to flag stdlib submodule imports as non-standard.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
UnsafeImportsML now works with both ast.ImportFrom and ast.Import AST
nodes tu support Ext1/2/4 opcodes.

The eval check is now independent of the UNSAFE_IMPORTS branch,
so it also triggers for module listed in UNSAFE_IMPORTS.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant