Repository navigation
Rename the asyncio SQLAlchemy adapter classes to CapWords and enforce N801 - #1151
Conversation
Rename AsyncAdapt_pyathena_cursor, AsyncAdapt_pyathena_connection, and AsyncAdapt_pyathena_dbapi to AthenaAioAdaptedCursor, AthenaAioAdaptedConnection, and AthenaAioAdaptedDBAPI without keeping the old names, and remove the N801 exclusion for pyathena/aio/sqlalchemy/base.py so that ruff rejects such names. Closes #1147 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
||
|
|
||
| class AsyncAdapt_pyathena_cursor: | ||
| class AthenaAioAdaptedCursor: |
There was a problem hiding this comment.
Self-review round one (implementation behavior): CLEAN
Scope: git diff a667abd4a8f8d91ff6b68fd8e3b49e12fe8f0a0b..14f636c3a7858ead1201a6d5894ea01e1923bae5 (pyathena/aio/sqlalchemy/base.py, pyproject.toml, tests/pyathena/aio/sqlalchemy/test_base.py, tests/pyathena/sqlalchemy/test_base.py).
- Behavior: pure rename of the three adapter classes; bodies,
__slots__, and theimport_dbapi()/dbapi()return objects are unchanged. SQLAlchemy receives the DBAPI object fromimport_dbapi()and never looks the classes up by name;git grep -i asyncadaptfinds no string-based or dynamic lookup,__all__, or Sphinxautoclassentry for them (only SQLAlchemy's ownpool.AsyncAdaptedQueuePoolremains). - Framework contracts: the
awsathena+aio*entry points inpyproject.toml:68-72name theAthenaAio*Dialectclasses, not the adapters. - Lint: removing the N801 exclusion leaves
just lintgreen, andruff check --select N801rejects a temporaryclass AsyncAdapt_pyathena_cursor:underpyathena/aio/sqlalchemy/. The N802 exclusion forcompiler.pystays as required. - Tests: references and the test class name (
TestAthenaAioAdaptedCursor) follow the rename; no new behavior needs new coverage.tests/pyathena/aio/sqlalchemy/(53 passed) andjust test sqla-async(589 passed, 759 skipped) exercise the adapters end to end.
Findings: none.
|
|
||
|
|
||
| class AsyncAdapt_pyathena_dbapi: | ||
| class AthenaAioAdaptedDBAPI: |
There was a problem hiding this comment.
Self-review round two (compatibility, operations, factual claims): CLEAN
Scope: git diff a667abd4a8f8d91ff6b68fd8e3b49e12fe8f0a0b..14f636c3a7858ead1201a6d5894ea01e1923bae5, plus the PR description.
- Compatibility: code importing the old names from
pyathena.aio.sqlalchemy.basebreaks, with no alias, as Rename the asyncio SQLAlchemy adapter classes to CapWords and enforce N801 #1147 decided; the PR's release-note section states it.gh search code AsyncAdapt_pyathenaoutside this repo finds only vendored copies of PyAthena and package-metadata dumps, no importer. 3.x is not affected (master only). - Upstream drift: master advanced to 0ebc6e7 (Resume benchmark fleet jobs after Spot interruptions #1145, benchmarks only). A temporary merge of the head with that master passes
ruff check .including N801, so the removed exclusion does not reject any newly merged class name. - Operations:
pyproject.tomlis a shared path intest.yaml, so marking Ready runs the full AWS suites; no AWS resources, permissions, or request patterns change. - Claims: the old→new table, the acronym convention (
AthenaDDLCompiler,DBAPITypeObject), the N802 rationale, the entry-point claim, and the recorded test commands/results match the tree and the local runs at 14f636c.
Findings: none.
There was a problem hiding this comment.
Round-two addendum (issue premise check): in SQLAlchemy 2.0.46 (the locked version), engine/create.py, engine/default.py, engine/interfaces.py, pool/base.py, and connectors/asyncio.py use __class__.__name__ only in log and error messages for the dialect, pool, and exception classes, never to locate the DBAPI adapter. The renamed classes do not subclass SQLAlchemy's AsyncAdapt_dbapi_* bases (only the connection subclasses AdaptedConnection), so no inherited name-based behavior changes. Round two remains CLEAN.
| "pyathena/sqlalchemy/compiler.py" = [ | ||
| "N802", # SQLAlchemy TypeCompiler requires visit_UPPERCASE method names | ||
| ] | ||
| "pyathena/aio/sqlalchemy/base.py" = [ |
There was a problem hiding this comment.
Independent review (relayed): CLEAN
- Reviewer: Codex CLI 0.162.1, model
gpt-6-astra, reasoning effortmax, sandboxread-only, session01a13002-267f-7c01-a92e-a8981f5b31c9. - Scope:
git diff a667abd4a8f8d91ff6b68fd8e3b49e12fe8f0a0b..14f636c3a7858ead1201a6d5894ea01e1923bae5on a clean detached snapshot of 14f636c, plus the locked SQLAlchemy 2.0.46 sources. The prompt left out the PR number, the description, and the self-review results. - Constraints: review only, so no edits, builds, tests, network, or GitHub access. This is a static review. The snapshot and the PR worktree were unchanged afterwards.
Reviewer output:
Covered the exact four-file diff and supplied patch, repository conventions, the full tracked tree, dialect registration and callers, Ruff/pytest configuration, changed tests, and the supplied SQLAlchemy 2.0.46 sources.
CLEAN — no actionable defects introduced by this diff.
- References: No old adapter names or former test-class references remain in tracked files. Imports, annotations, docstrings, constructors, factories, and string-based registration paths are consistent. No compatibility aliases remain.
- SQLAlchemy compatibility: SQLAlchemy constructs the DBAPI through dialect factories and calls its methods; these paths do not require the old names or inheritance from
AsyncAdapt_*. The connection adapter retainsAdaptedConnectioninheritance. That interface predates the declared>=2.0.0minimum.- Ruff: Removing N801 is correct: all classes in the module now use CapWords. No other exclusion needs changing. The compiler’s N802 exclusion remains necessary for SQLAlchemy’s
visit_UPPERCASEdispatch.- Naming:
AthenaAioAdaptedCursor,AthenaAioAdaptedConnection, andAthenaAioAdaptedDBAPIconsistently follow the package’s existingAthenaAio*naming.- Tests: All three changed Python files exactly match their base versions after applying the intended name substitutions. Assertions, parameter IDs, fixtures, cleanup, and scenario coverage are preserved.
TestAthenaAioAdaptedCursorretains pytest discovery and follows the repository’s object-focused test-class convention.The direct-import break is intentional. This is a static review: no lint, builds, tests, or network access occurred. Dependency inspection covered 2.0.46, not every release permitted by the unbounded
>=2.0.0requirement. HEAD and the clean working tree remain unchanged.
WHAT
Rename the asyncio SQLAlchemy adapter classes in
pyathena/aio/sqlalchemy/base.pyto CapWords names, without keeping the old names:AsyncAdapt_pyathena_cursorAthenaAioAdaptedCursorAsyncAdapt_pyathena_connectionAthenaAioAdaptedConnectionAsyncAdapt_pyathena_dbapiAthenaAioAdaptedDBAPIThe new names follow
AthenaAioDialectand the package's convention of keeping acronyms uppercase (AthenaDDLCompiler,DBAPITypeObject).The PR also removes the N801 exclusion for
pyathena/aio/sqlalchemy/base.pyfrom[tool.ruff.lint.per-file-ignores], sojust lintnow rejects such class names. The N802 exclusion forpyathena/sqlalchemy/compiler.pystays, because SQLAlchemy's type compiler dispatches tovisit_<TYPE>methods by name.The references in docstrings and in
tests/pyathena/aio/sqlalchemy/test_base.pyandtests/pyathena/sqlalchemy/test_base.pyare updated. The test classTestAsyncAdaptPyathenaCursorbecomesTestAthenaAioAdaptedCursorto match the class it tests.Release note (breaking)
The asyncio SQLAlchemy adapter classes in
pyathena.aio.sqlalchemy.baseare renamed, with no aliases for the old names:AsyncAdapt_pyathena_cursor→AthenaAioAdaptedCursor,AsyncAdapt_pyathena_connection→AthenaAioAdaptedConnection,AsyncAdapt_pyathena_dbapi→AthenaAioAdaptedDBAPI. Code that imports the old names must use the new ones. Engines created with theawsathena+aio*URLs are unaffected.WHY
Closes #1147.
The
AsyncAdapt_*names copied SQLAlchemy's own asyncio adapters, but SQLAlchemy does not require them: the dialect hands its DBAPI object to SQLAlchemy throughimport_dbapi(), and nothing looks the classes up by name.TEST
Tested commit: 14f636c.
just formatandjust lint: passed (ruff check, ruff format check, mypy, cfn-lint, license headers).uvx ruff@0.14.14 check --select N801on a temporaryclass AsyncAdapt_pyathena_cursor:underpyathena/aio/sqlalchemy/reports N801 (file deleted afterwards).uv run --env-file .env pytest -n 1 tests/pyathena/aio/sqlalchemy/test_base.py::TestAthenaAioAdaptedCursor tests/pyathena/sqlalchemy/test_base.py::TestAthenaDialect::test_internal_cursor_leaves_out_default_cursor_options: 6 passed.uv run --env-file .env pytest -n 4 tests/pyathena/aio/sqlalchemy/: 53 passed.uv run --env-file .env just test sqla-async: 589 passed, 759 skipped.Not run locally: the remaining
just test pyathenasuites andjust test sqla; the synchronous dialect code is unchanged. CI covers them once the PR is Ready.🤖 Generated with Claude Code