Skip to content

test(sqlalchemy): cover AthenaTimestamp.process and simplify AthenaDate isinstance - #744

Merged
laughingman7743 merged 1 commit into
masterfrom
fix/athena-timestamp-test-and-date-isinstance
Jul 26, 2026
Merged

test(sqlalchemy): cover AthenaTimestamp.process and simplify AthenaDate isinstance#744
laughingman7743 merged 1 commit into
masterfrom
fix/athena-timestamp-test-and-date-isinstance

Conversation

@laughingman7743

Copy link
Copy Markdown
Member

Follow-up to #743.

WHAT

  • Add TestAthenaTimestamp covering AthenaTimestamp.process: the millisecond truncation, a whole-second datetime, and the non-datetime fallback. Add the matching fallback case to TestAthenaDate.
  • Simplify AthenaDate.process: isinstance(value, (date, datetime))isinstance(value, date), and narrow the annotation to date | Any.

WHY

#743 fixed a missing return in AthenaDate.process. Its sibling AthenaTimestamp.process is correct today, but had no test — nothing guarded the strftime("%f")[:-3] slice that narrows six digits to the three Athena TIMESTAMP supports. These are pure-logic tests, so they need no AWS credentials.

datetime is a subclass of date, so the tuple in the isinstance check was redundant and the date | datetime | Any annotation collapsed to Any.

Sweep for the same bug class

Since #742 was a computed-then-discarded expression, I checked whether the tree holds others. No ruff rule catches thisB018 deliberately skips strings so it cannot see a bare f-string, and --select ALL on a reduced case reports nothing. An AST walk over pyathena/, tests/, and benchmarks/ for discarded ast.Expr statements returned two hits, both legitimate:

  • pyathena/common.py:33 — PEP 258 attribute docstring for the OnPollCallback alias
  • tests/pyathena/sqlalchemy/test_types.py:76 — intentional __getitem__ inside pytest.raises(KeyError)

#742 was the only real instance.

…te isinstance

Follow-up to #743, which fixed a missing return in AthenaDate.process.

AthenaTimestamp.process is the sibling of that method and had no unit test,
so nothing guarded its millisecond truncation: strftime("%f") emits six
digits and the [:-3] slice narrows them to the three Athena TIMESTAMP
supports. Add cases for that truncation, for a whole-second datetime, and
for the non-datetime fallback, plus the matching fallback case for
AthenaDate.

Also drop the redundant datetime from AthenaDate.process's isinstance
check: datetime is a subclass of date, so isinstance(value, date) already
matches both. The annotation is narrowed to date | Any for the same reason.

Swept the whole tree for the #742 bug class (an expression statement whose
value is computed and discarded) with an AST walk. No ruff rule catches it
- B018 deliberately skips strings so it cannot see a bare f-string - and
the only other hits were a PEP 258 attribute docstring and an intentional
__getitem__ inside pytest.raises. #742 was the sole real instance.
@laughingman7743
laughingman7743 marked this pull request as ready for review July 26, 2026 01:09
@laughingman7743
laughingman7743 merged commit 53617fc into master Jul 26, 2026
15 checks passed
@laughingman7743
laughingman7743 deleted the fix/athena-timestamp-test-and-date-isinstance branch July 26, 2026 01:09
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.

1 participant