Skip to content

Rename the asyncio SQLAlchemy adapter classes to CapWords and enforce N801 - #1151

Merged
laughingman7743 merged 1 commit into
masterfrom
refactor/1147-aio-adapter-capwords
Oct 12, 2026
Merged

laughingman7743 merged 1 commit into
masterfrom
refactor/1147-aio-adapter-capwords

Conversation

@laughingman7743

Copy link
Copy Markdown
Member

WHAT

Rename the asyncio SQLAlchemy adapter classes in pyathena/aio/sqlalchemy/base.py to CapWords names, without keeping the old names:

Old name New name
AsyncAdapt_pyathena_cursor AthenaAioAdaptedCursor
AsyncAdapt_pyathena_connection AthenaAioAdaptedConnection
AsyncAdapt_pyathena_dbapi AthenaAioAdaptedDBAPI

The new names follow AthenaAioDialect and the package's convention of keeping acronyms uppercase (AthenaDDLCompiler, DBAPITypeObject).

The PR also removes the N801 exclusion for pyathena/aio/sqlalchemy/base.py from [tool.ruff.lint.per-file-ignores], so just lint now rejects such class names. The N802 exclusion for pyathena/sqlalchemy/compiler.py stays, because SQLAlchemy's type compiler dispatches to visit_<TYPE> methods by name.

The references in docstrings and in tests/pyathena/aio/sqlalchemy/test_base.py and tests/pyathena/sqlalchemy/test_base.py are updated. The test class TestAsyncAdaptPyathenaCursor becomes TestAthenaAioAdaptedCursor to match the class it tests.

Release note (breaking)

The asyncio SQLAlchemy adapter classes in pyathena.aio.sqlalchemy.base are 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 the awsathena+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 through import_dbapi(), and nothing looks the classes up by name.

TEST

Tested commit: 14f636c.

  • just format and just lint: passed (ruff check, ruff format check, mypy, cfn-lint, license headers).
  • With the exclusion removed, uvx ruff@0.14.14 check --select N801 on a temporary class AsyncAdapt_pyathena_cursor: under pyathena/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 pyathena suites and just test sqla; the synchronous dialect code is unchanged. CI covers them once the PR is Ready.

🤖 Generated with Claude Code

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:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the import_dbapi()/dbapi() return objects are unchanged. SQLAlchemy receives the DBAPI object from import_dbapi() and never looks the classes up by name; git grep -i asyncadapt finds no string-based or dynamic lookup, __all__, or Sphinx autoclass entry for them (only SQLAlchemy's own pool.AsyncAdaptedQueuePool remains).
  • Framework contracts: the awsathena+aio* entry points in pyproject.toml:68-72 name the AthenaAio*Dialect classes, not the adapters.
  • Lint: removing the N801 exclusion leaves just lint green, and ruff check --select N801 rejects a temporary class AsyncAdapt_pyathena_cursor: under pyathena/aio/sqlalchemy/. The N802 exclusion for compiler.py stays 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) and just test sqla-async (589 passed, 759 skipped) exercise the adapters end to end.

Findings: none.



class AsyncAdapt_pyathena_dbapi:
class AthenaAioAdaptedDBAPI:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.base breaks, 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_pyathena outside 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.toml is a shared path in test.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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pyproject.toml
"pyathena/sqlalchemy/compiler.py" = [
"N802", # SQLAlchemy TypeCompiler requires visit_UPPERCASE method names
]
"pyathena/aio/sqlalchemy/base.py" = [

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (relayed): CLEAN

  • Reviewer: Codex CLI 0.162.1, model gpt-6-astra, reasoning effort max, sandbox read-only, session 01a13002-267f-7c01-a92e-a8981f5b31c9.
  • Scope: git diff a667abd4a8f8d91ff6b68fd8e3b49e12fe8f0a0b..14f636c3a7858ead1201a6d5894ea01e1923bae5 on 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 retains AdaptedConnection inheritance. That interface predates the declared >=2.0.0 minimum.
  • 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_UPPERCASE dispatch.
  • Naming: AthenaAioAdaptedCursor, AthenaAioAdaptedConnection, and AthenaAioAdaptedDBAPI consistently follow the package’s existing AthenaAio* 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. TestAthenaAioAdaptedCursor retains 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.0 requirement. HEAD and the clean working tree remain unchanged.

@laughingman7743
laughingman7743 marked this pull request as ready for review October 12, 2026 12:12
@laughingman7743
laughingman7743 merged commit 65c1414 into master Oct 12, 2026
13 checks passed
@laughingman7743
laughingman7743 deleted the refactor/1147-aio-adapter-capwords branch October 12, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename the asyncio SQLAlchemy adapter classes to CapWords and enforce N801

1 participant