Skip to content

refactor: Remove unused imports across src#6095

Closed
Jacksunwei wants to merge 1 commit into
mainfrom
chore/remove-unused-imports
Closed

refactor: Remove unused imports across src#6095
Jacksunwei wants to merge 1 commit into
mainfrom
chore/remove-unused-imports

Conversation

@Jacksunwei

Copy link
Copy Markdown
Collaborator

Summary

Removes genuinely unused imports throughout src/. No behavior change — a no-brainer cleanup.

Imports that look unused but are intentional are preserved:

  • Re-export hubs keep their symbols via the import X as X convention (dependency shims, adk_web_server, a2a/executor/utils, tools/api_registry).
  • Optional-dependency availability probes inside try/except and a few defensive imports are kept with # noqa: F401.

Also annotates Context._output_for_ancestors once before the if/else instead of in both branches, fixing a latent mypy [no-redef] that surfaces once the file is touched.

Test plan

  • import google.adk smoke test passes
  • No __init__.py public re-exports removed
  • Tooling/enforcement (ruff config + pre-commit hook) deliberately kept out — that lands in a follow-up PR

Delete genuinely unused imports throughout src/. Imports that look unused
but are intentional are preserved:
- Re-export hubs keep their symbols via the `import X as X` convention
  (dependency shims, adk_web_server, a2a executor utils, tools/api_registry).
- Optional-dependency availability probes inside try/except and a few
  defensive imports are kept with `# noqa: F401`.

Also annotate Context._output_for_ancestors once before the if/else
instead of in both branches, fixing a latent mypy [no-redef] that
surfaces once the file is touched.

No behavior change.

Change-Id: I3fc08563409421ab83032aebc3d70973fd9767bf
@Jacksunwei Jacksunwei self-assigned this Jun 12, 2026
copybara-service Bot pushed a commit that referenced this pull request Jun 12, 2026
Merge #6095

## Summary

Removes genuinely unused imports throughout `src/`. No behavior change — a no-brainer cleanup.

Imports that *look* unused but are intentional are **preserved**:
- **Re-export hubs** keep their symbols via the `import X as X` convention (dependency shims, `adk_web_server`, `a2a/executor/utils`, `tools/api_registry`).
- **Optional-dependency availability probes** inside `try/except` and a few defensive imports are kept with `# noqa: F401`.

Also annotates `Context._output_for_ancestors` once before the `if/else` instead of in both branches, fixing a latent mypy `[no-redef]` that surfaces once the file is touched.

## Test plan

- [x] `import google.adk` smoke test passes
- [x] No `__init__.py` public re-exports removed
- [x] Tooling/enforcement (ruff config + pre-commit hook) deliberately kept out — that lands in a follow-up PR

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
COPYBARA_INTEGRATE_REVIEW=#6095 from google:chore/remove-unused-imports e7c24f6
PiperOrigin-RevId: 931258421
@adk-bot

adk-bot commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Thank you @Jacksunwei for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit b79096a.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Jun 12, 2026
@adk-bot adk-bot closed this Jun 12, 2026
copybara-service Bot pushed a commit that referenced this pull request Jun 12, 2026
Merge #6097

## Summary

Adopts **ruff** to enforce unused-import (F401) hygiene going forward, so dead imports are caught automatically instead of relying on IDE highlights. (The bulk one-time cleanup already landed in #6095; this is just the tooling.)

- `[tool.ruff]` in `pyproject.toml`: select `F401`, exempt `__init__.py` (intentional public re-exports), and exclude four files that hardcode `googleapis.com` URLs so cleanup doesn't trip the `check-file-contents` mTLS policy.
- ruff pre-commit hook scoped to `src/`.
- `scripts/run_precommit_checks.py` (the no-git standalone runner) learns the ruff hook, passing `--force-exclude` so excludes are honored on explicit file args.
- Pin `ruff` in the dev extra to match the hook version.

## Test plan

- [x] `ruff check src/` passes (excludes honored)
- [x] pre-commit ruff hook runs green
- [x] standalone runner check/fix modes verified

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
COPYBARA_INTEGRATE_REVIEW=#6097 from google:chore/adopt-ruff-f401 b063652
PiperOrigin-RevId: 931304052
@Jacksunwei Jacksunwei deleted the chore/remove-unused-imports branch June 13, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants