fix: audit quickfixes — typos, DTZ007, remove stale pragmas#605
fix: audit quickfixes — typos, DTZ007, remove stale pragmas#605
Conversation
Co-authored-by: hairmare <116588+hairmare@users.noreply.github.com>
|
@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>
Done in 9bbdf8a. Here's what was added/updated: New test Updated New Updated Updated |
Audit of docs, code, and tests surfaced several correctness issues. This PR applies all quickfixes.
Doc/comment typos
cridlib/__init__.py: broken anchorgridlib.parse.parse→cridlib.parse.parsecridlib/strategy/__init__.py: dead link./present/→./now/(module isnow.py)tests/conftest.py:Configureation→ConfigurationREADME.md:pip -m install rabe-cridlib→pip install rabe-cridlibDTZ007 — clock timestamps were timezone-naive
Fragment clock values (e.g.
19930301T131200.00Z) were parsed viastrptimeinto a naivedatetime, silently discarding theZUTC indicator. Fixed with.replace(tzinfo=timezone.utc), removing the stale# TODOand# noqa: DTZ007(issue #244 is closed).The
CRID.startproperty docstring now documents UTC-awareness and includes a doctest showingcrid.start.tzinfo == timezone.utcand safe comparison withdatetime.now(timezone.utc). Theget()docstring example also shows the+00:00suffix.Tests and README doctest updated accordingly.
New tests demonstrating why the fix matters
test_start_is_utc_aware(test_lib.py): explicitly assertscrid.start.tzinfo is timezone.utcand thatcrid.start < datetime.now(timezone.utc)works without aTypeError— the comparison that would have failed before the fix.test_get_past(test_get.py): now also assertscrid.start.tzinfo is timezone.utcandcrid.start == ts, demonstrating round-trip UTC equality between the timestamp passed toget()and thestartextracted from the resulting CRID fragment.Remove unjustified
# pragma: no covercridlib/get.py'selif _ts > _now:branch andstrategy/future.py'sget_showfunction were excluded from coverage despitetest_get_futurealready exercising both paths end-to-end. Pragmas removed;future.pynow reports 17 covered statements (previously wholly excluded).New
tests/strategy/test_future.pyDedicated 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
_tzinstrategy/future.pyis 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.