transformers
e03c3539 - fix(tests_fetcher): handle `X as X` re-export syntax and duplicate module entries (#50253)

Commit
23 days ago
fix(tests_fetcher): handle `X as X` re-export syntax and duplicate module entries (#50253) * fix(tests_fetcher): handle \`X as X\` re-export syntax and duplicate module entries in extract_imports Two related bugs in `extract_imports` / `get_module_dependencies`: 1. `X as X` imports (PEP 484 public re-export convention) were silently dropped by the `^[A-Za-z0-9_]*$` filter — the space in e.g. `TextClassificationPipeline as TextClassificationPipeline` caused the whole name to fail the check. Fix: strip ` as <alias>` before filtering. 2. `dict(extract_imports(module))` in `get_module_dependencies` loses all but the last entry when multiple single-line imports target the same module. With bulk `from .pipelines import (X, Y, ...)` this was one tuple; with individual `from .pipelines import X as X` lines it becomes N tuples, and `dict()` keeps only the last. Fix: merge entries explicitly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(tests_fetcher): skip missing deps in transitive closure instead of raising On case-insensitive filesystems (Windows), uppercase constants like FULL_ATTENTION can be resolved as filenames (full_attention.py), producing phantom dep entries that are not in direct_deps. Change raise to continue to skip them gracefully. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Revert "fix(tests_fetcher): skip missing deps in transitive closure instead of raising" This reverts commit 8dcdbeca5b1f4289b9c3f687a6ae84068c2f2480. * tests(tests_fetcher): add regression tests for X as X imports and update multimodal dep assertion - Add test_extract_imports_x_as_x: verifies X as X and X as Y import forms are no longer silently dropped (regression for commit 50145474b7 / PR #39729) - Add test_get_module_dependencies_same_module_multiple_single_line_imports: verifies multiple single-line imports targeting the same module are all collected (regression for dict() key-collision bug) - Remove isdisjoint assertion for tokenization_qwen2.py: after fixing the fetcher to correctly handle X as X imports, Qwen2Tokenizer is now properly traced from test_modeling_qwen2_audio.py to tokenization_qwen2.py — the assertion was only true because the fetcher was broken Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(tests_fetcher): comment out isdisjoint assertion, explain X-as-Y blast radius PR #50253 fixed the "X as Y" import bug in extract_imports. As a result, tokenization_qwen2.py is now correctly traced as a dep of qwen2_audio tests through gguf_tokenizer_mapping.py → configuration_utils.py → all model tests. The old isdisjoint assertion tested broken (pre-fix) behavior. Comment it out with a detailed explanation so reviewers understand why it no longer holds and that the blast-radius reduction is a separate concern. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
Author
Parents
Loading