Skip to content

fix: audit quickfixes — typos, DTZ007, remove stale pragmas#605

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/audit-docs-code-tests
Draft

fix: audit quickfixes — typos, DTZ007, remove stale pragmas#605
Copilot wants to merge 3 commits intomainfrom
copilot/audit-docs-code-tests

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

Audit of docs, code, and tests surfaced several correctness issues. This PR applies all quickfixes.

Doc/comment typos

  • cridlib/__init__.py: broken anchor gridlib.parse.parsecridlib.parse.parse
  • cridlib/strategy/__init__.py: dead link ./present/./now/ (module is now.py)
  • tests/conftest.py: ConfigureationConfiguration
  • README.md: pip -m install rabe-cridlibpip install rabe-cridlib

DTZ007 — clock timestamps were timezone-naive

Fragment clock values (e.g. 19930301T131200.00Z) were parsed via strptime into a naive datetime, silently discarding the Z UTC indicator. Fixed with .replace(tzinfo=timezone.utc), removing the stale # TODO and # noqa: DTZ007 (issue #244 is closed).

# before — naive datetime
crid.start  # datetime(1993, 3, 1, 13, 12)

# after — UTC-aware
crid.start  # datetime(1993, 3, 1, 13, 12, tzinfo=timezone.utc)

The CRID.start property docstring now documents UTC-awareness and includes a doctest showing crid.start.tzinfo == timezone.utc and safe comparison with datetime.now(timezone.utc). The get() docstring example also shows the +00:00 suffix.

Tests and README doctest updated accordingly.

New tests demonstrating why the fix matters

  • test_start_is_utc_aware (test_lib.py): explicitly asserts crid.start.tzinfo is timezone.utc and that crid.start < datetime.now(timezone.utc) works without a TypeError — the comparison that would have failed before the fix.
  • test_get_past (test_get.py): now also asserts crid.start.tzinfo is timezone.utc and crid.start == ts, demonstrating round-trip UTC equality between the timestamp passed to get() and the start extracted from the resulting CRID fragment.

Remove unjustified # pragma: no cover

cridlib/get.py's elif _ts > _now: branch and strategy/future.py's get_show function were excluded from coverage despite test_get_future already exercising both paths end-to-end. Pragmas removed; future.py now reports 17 covered statements (previously wholly excluded).

New tests/strategy/test_future.py

Dedicated unit tests for the future strategy covering both the match case (timestamp falls within a scheduled show) and the no-match case (timestamp beyond the 7-day window), independent from test_get.py.

Proposed next steps

  • _tz in strategy/future.py is fetched from the LibreTime response but never used — show start/end times are blindly treated as UTC. Could cause wrong show matching when the station timezone is not UTC.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: hairmare <116588+hairmare@users.noreply.github.com>
Copilot AI changed the title [WIP] Audit documentation, code, and tests with quick fixes fix: audit quickfixes — typos, DTZ007, remove stale pragmas Feb 27, 2026
@hairmare
Copy link
Member

@copilot update the pr to demonstrate why the tzinfo change makes sense, update docs and ad tests

…e docs

Co-authored-by: hairmare <116588+hairmare@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 27, 2026

@copilot update the pr to demonstrate why the tzinfo change makes sense, update docs and ad tests

Done in 9bbdf8a. Here's what was added/updated:

New test test_start_is_utc_aware (test_lib.py) — explicitly documents the problem and the fix: before the change crid.start was naive, so crid.start < datetime.now(timezone.utc) would raise TypeError; now crid.start.tzinfo is timezone.utc and the comparison works.

Updated test_get_past (test_get.py) — asserts crid.start.tzinfo is timezone.utc and crid.start == ts, showing round-trip equality between the UTC timestamp passed to get() and the UTC-aware start extracted from the resulting CRID fragment.

New tests/strategy/test_future.py — dedicated unit tests for the future strategy covering both the match and no-match cases, independent from test_get.py.

Updated CRID.start property docstring (lib.py) — documents UTC-awareness and includes a doctest that shows crid.start.tzinfo == timezone.utc and the safe comparison with datetime.now(timezone.utc).

Updated get() docstring example (get.py) — the ellipsis pattern now includes +00:00 to make the UTC output visible.

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.

2 participants