Remove unused imports#895
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (57)
💤 Files with no reviewable changes (26)
📝 WalkthroughWalkthroughThis pull request performs a comprehensive cleanup of unused imports across the entire Cassandra Python driver codebase and test suite. Changes include removing unused module imports (sys, unittest, logging, platform, time, socket, uuid), removing unused imports from module dependency lists (InvalidRequest, ConsistencyLevel, BatchStatement, various test utilities), and adding noqa annotations to intentional module-level re-exports. The cassandra/protocol.py file receives special attention with added documentation explaining that imports marked noqa are required for dynamic resolution in ResultMessage.type_codes. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
CI summaryAll checks relevant to this change are green. The matrix result:
Why
|
Summary
Removes unused imports across the driver and the test suite, split into two commits:
cassandra/packagetests/Detected with
ruff --select F401.Notes on preserved imports
The following "unused" imports were intentionally kept, because they are not truly unused:
cassandra/protocol.pyresolves 21 cqltype classes by name viaglobals()[name]to buildResultMessage.type_codes. Removing them breaks import withKeyError. Kept with a# noqa: F401block and an explanatory comment.cassandra/connection.pyre-exportsShardingInfo(consumed viafrom cassandra.connection import ShardingInfo, e.g.tests/unit/test_shard_aware.py). Kept with# noqa: F401.try/except ImportErrorused to detect optional dependencies (kerberos,numpy,cryptography,gremlin_python,ccmlib.common,make_recv_results_rows).cassandra/datastax/graph/__init__.py.Testing
build_ext --inplace/uv sync --reinstall-package scylla-driver) so the edited.pysources are actually exercised.test_cluster.pyfailures unrelated to this change; reactor-timer tests excluded as they hang in the sandbox).