Skip to content

generate: python dx_ignore_import drops the hand-written deps for that import (part of #9237) #9296

Closed

Description

@TrapsterDK

Problem

# gazelle:dx_ignore_import python <module> stops the import from resolving, and the merge then deletes the hand-written deps that provide that module. The test still imports it, so it fails at runtime.

Found in #9279 (review on #9237):

  • python/tests/BUILD.bazel ignores rpds; generate removes deps = ["@rust_sdist_pypi//rpds_py"] from rust_sdist_test, which imports rpds (rust_sdist_test.py:46, :70).
  • python/tests/fixtures/native_ext/BUILD.bazel ignores dxlinked, dxnative and python; generate removes :dxlinked, :dxnative and the Windows @rules_python//python/runfiles select from native_ext_test, which imports all three. The test is Windows-only, so a Linux run never shows the ImportError.

Reproduction

On main (570927c):

tools/dx generate python/tests python/tests/fixtures/native_ext

reports ignored_import notices for rpds, dxlinked, dxnative, python and proposes modifying both BUILD files; --apply drops the deps listed above.

Minimal case: a package with # gazelle:dx_ignore_import python foo, a python_test whose source does import foo, and deps = [":foo"]. Generate removes :foo.

Fix

Either keep existing deps on a rule that has an ignored import, or document that such deps need # keep and make generate report the drop. The first matches what users expect from "skip one import".

Done when

Generate on main proposes no change to these two packages and both tests keep their deps.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xut2hzpb4qWNZKpDCrwUz7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions