Skip to content

Remove unused imports#895

Merged
dkropachev merged 2 commits into
scylladb:masterfrom
mykaul:remove-unused-imports
Jun 30, 2026
Merged

Remove unused imports#895
dkropachev merged 2 commits into
scylladb:masterfrom
mykaul:remove-unused-imports

Conversation

@mykaul

@mykaul mykaul commented Jun 3, 2026

Copy link
Copy Markdown

Summary

Removes unused imports across the driver and the test suite, split into two commits:

  • Remove unused imports from driver codecassandra/ package
  • Remove unused imports from teststests/

Detected with ruff --select F401.

Notes on preserved imports

The following "unused" imports were intentionally kept, because they are not truly unused:

  • Dynamically resolved: cassandra/protocol.py resolves 21 cqltype classes by name via globals()[name] to build ResultMessage.type_codes. Removing them breaks import with KeyError. Kept with a # noqa: F401 block and an explanatory comment.
  • Public re-export: cassandra/connection.py re-exports ShardingInfo (consumed via from cassandra.connection import ShardingInfo, e.g. tests/unit/test_shard_aware.py). Kept with # noqa: F401.
  • Availability probes: imports inside try/except ImportError used to detect optional dependencies (kerberos, numpy, cryptography, gremlin_python, ccmlib.common, make_recv_results_rows).
  • Package re-export hubs: genuine public re-exports in cassandra/datastax/graph/__init__.py.

Testing

  • Rebuilt the Cython extensions (build_ext --inplace / uv sync --reinstall-package scylla-driver) so the edited .py sources are actually exercised.
  • Unit suite: 714 passed, 37 skipped (2 pre-existing test_cluster.py failures unrelated to this change; reactor-timer tests excluded as they hang in the sandbox).
  • All 45 modified test files byte-compile cleanly.

Note: integration tests were not run here (require a live CCM/Scylla environment).

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0bdb4d95-ffbb-4052-b21e-a5270105b64b

📥 Commits

Reviewing files that changed from the base of the PR and between e5c83c3 and 9116334.

📒 Files selected for processing (57)
  • cassandra/cluster.py
  • cassandra/concurrent.py
  • cassandra/connection.py
  • cassandra/cqlengine/connection.py
  • cassandra/cqlengine/query.py
  • cassandra/cqltypes.py
  • cassandra/datastax/cloud/__init__.py
  • cassandra/encoder.py
  • cassandra/io/asyncioreactor.py
  • cassandra/io/asyncorereactor.py
  • cassandra/pool.py
  • cassandra/protocol.py
  • tests/integration/cqlengine/__init__.py
  • tests/integration/cqlengine/base.py
  • tests/integration/cqlengine/connections/test_connection.py
  • tests/integration/cqlengine/management/test_management.py
  • tests/integration/cqlengine/model/test_model.py
  • tests/integration/cqlengine/model/test_model_io.py
  • tests/integration/cqlengine/query/test_named.py
  • tests/integration/cqlengine/statements/test_select_statement.py
  • tests/integration/cqlengine/statements/test_update_statement.py
  • tests/integration/cqlengine/test_connections.py
  • tests/integration/cqlengine/test_ifexists.py
  • tests/integration/cqlengine/test_ttl.py
  • tests/integration/long/test_large_data.py
  • tests/integration/simulacron/__init__.py
  • tests/integration/simulacron/test_cluster.py
  • tests/integration/simulacron/test_connection.py
  • tests/integration/simulacron/test_empty_column.py
  • tests/integration/simulacron/test_endpoint.py
  • tests/integration/simulacron/utils.py
  • tests/integration/standard/conftest.py
  • tests/integration/standard/test_cluster.py
  • tests/integration/standard/test_concurrent.py
  • tests/integration/standard/test_concurrent_schema_change_and_node_kill.py
  • tests/integration/standard/test_custom_cluster.py
  • tests/integration/standard/test_custom_payload.py
  • tests/integration/standard/test_custom_protocol_handler.py
  • tests/integration/standard/test_metadata.py
  • tests/integration/standard/test_policies.py
  • tests/integration/standard/test_query.py
  • tests/integration/standard/test_query_paging.py
  • tests/integration/standard/test_shard_aware.py
  • tests/integration/standard/test_single_interface.py
  • tests/integration/standard/test_types.py
  • tests/integration/upgrade/__init__.py
  • tests/integration/upgrade/test_upgrade.py
  • tests/stress_tests/test_load.py
  • tests/unit/advanced/test_graph.py
  • tests/unit/advanced/test_insights.py
  • tests/unit/advanced/test_metadata.py
  • tests/unit/io/test_asyncorereactor.py
  • tests/unit/io/test_twistedreactor.py
  • tests/unit/test_endpoints.py
  • tests/unit/test_host_connection_pool.py
  • tests/unit/test_marshalling.py
  • tests/unit/test_protocol.py
💤 Files with no reviewable changes (26)
  • tests/integration/simulacron/test_empty_column.py
  • tests/unit/io/test_asyncorereactor.py
  • tests/integration/simulacron/utils.py
  • cassandra/datastax/cloud/init.py
  • tests/integration/cqlengine/model/test_model.py
  • cassandra/concurrent.py
  • tests/integration/upgrade/test_upgrade.py
  • tests/integration/cqlengine/base.py
  • tests/integration/standard/test_concurrent_schema_change_and_node_kill.py
  • tests/integration/cqlengine/model/test_model_io.py
  • cassandra/io/asyncorereactor.py
  • cassandra/encoder.py
  • tests/unit/test_protocol.py
  • tests/integration/standard/conftest.py
  • tests/integration/standard/test_query_paging.py
  • tests/integration/cqlengine/init.py
  • tests/integration/simulacron/test_endpoint.py
  • tests/unit/io/test_twistedreactor.py
  • tests/unit/test_marshalling.py
  • tests/integration/simulacron/init.py
  • tests/integration/cqlengine/management/test_management.py
  • tests/integration/standard/test_concurrent.py
  • tests/integration/simulacron/test_connection.py
  • cassandra/pool.py
  • tests/stress_tests/test_load.py
  • tests/unit/test_host_connection_pool.py
✅ Files skipped from review due to trivial changes (21)
  • tests/integration/standard/test_custom_cluster.py
  • cassandra/cqlengine/connection.py
  • tests/integration/standard/test_policies.py
  • cassandra/connection.py
  • tests/integration/long/test_large_data.py
  • tests/integration/cqlengine/test_connections.py
  • tests/integration/cqlengine/connections/test_connection.py
  • tests/integration/standard/test_custom_payload.py
  • tests/integration/cqlengine/test_ifexists.py
  • tests/integration/standard/test_shard_aware.py
  • tests/integration/standard/test_single_interface.py
  • tests/integration/cqlengine/statements/test_update_statement.py
  • cassandra/io/asyncioreactor.py
  • tests/integration/cqlengine/statements/test_select_statement.py
  • tests/unit/advanced/test_graph.py
  • tests/integration/simulacron/test_cluster.py
  • tests/unit/advanced/test_insights.py
  • tests/unit/test_endpoints.py
  • tests/integration/cqlengine/query/test_named.py
  • cassandra/protocol.py
  • tests/integration/standard/test_metadata.py
🚧 Files skipped from review as they are similar to previous changes (10)
  • tests/unit/advanced/test_metadata.py
  • tests/integration/upgrade/init.py
  • cassandra/cqltypes.py
  • tests/integration/standard/test_custom_protocol_handler.py
  • tests/integration/cqlengine/test_ttl.py
  • cassandra/cqlengine/query.py
  • tests/integration/standard/test_query.py
  • cassandra/cluster.py
  • tests/integration/standard/test_cluster.py
  • tests/integration/standard/test_types.py

📝 Walkthrough

Walkthrough

This pull request removes unused imports across runtime modules and test modules, including standard-library imports, Cassandra driver symbols, and integration test helpers. It also keeps a few module-level imports in place with # noqa: F401 or comments where the imported names are still required for re-export or dynamic lookup.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: removing unused imports.
Description check ✅ Passed The description includes a summary, rationale, preserved-import notes, and testing results, which substantially matches the template.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mykaul

mykaul commented Jun 3, 2026

Copy link
Copy Markdown
Author

CI summary

All checks relevant to this change are green. The matrix result:

  • build, source-dist, wheels, snyk: pass
  • test asyncio / asyncore / libev across Python 3.11–3.14 (and asyncio 3.14t): pass
  • test libev (3.14t): 1 failing integration test (see below)
  • jira-sync: fail — expected org automation that requires a Jira key; unrelated to code

Why test libev (3.14t) failed (not caused by this PR)

FAILED tests/integration/standard/test_client_routes.py::TestPrivateLinkConnectivity::test_queries_succeed_through_proxy
       - AttributeError: 'NoneType' object has no attribute 'v'
1 failed, 934 passed, 73 skipped, 12 xfailed

This PR only removes unused imports. The failure is unrelated:

  1. A missing import would surface as NameError/ImportError, not an AttributeError deep inside PrivateLink proxy logic.
  2. The same test passed on test asyncio (3.14t) and on every other interpreter/reactor combination — it failed only on the libev free-threaded flavor, which points to a flake / 3.14t-specific environment issue rather than a logic regression.
  3. The trailing RuntimeError: cannot schedule new futures after interpreter shutdown messages are teardown noise typical of free-threaded (3.14t) shutdown, not a test assertion failure.

No import touched by this PR is referenced by test_client_routes.py.

@mykaul mykaul marked this pull request as ready for review June 3, 2026 09:56
@mykaul mykaul force-pushed the remove-unused-imports branch from e5c83c3 to 9116334 Compare June 29, 2026 22:09
@dkropachev dkropachev merged commit e48f3c6 into scylladb:master Jun 30, 2026
19 of 21 checks passed
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.

3 participants