Skip to content

fix(examples): parse live API published timestamps on Python 3.8-3.10 - #13

Merged
Autumn-Atlas merged 1 commit into
masterfrom
agent/monitor-parse-api-published
Sep 30, 2026
Merged

Autumn-Atlas merged 1 commit into
masterfrom
agent/monitor-parse-api-published

Conversation

@Autumn-Atlas

Copy link
Copy Markdown
Contributor

Problem

The Search API sends published as 2026-09-30 05:04:18 +0000, with a space before the offset. datetime.fromisoformat accepts that only on Python 3.11 and later. On Python 3.8–3.10, which this package supports (python_requires=">=3.8"), the company news monitor's live mode stops at the first real article:

error: news item published must be an RFC 3339 timestamp

The fixtures use RFC 3339 (2026-08-05T07:30:00Z), so the tests never exercised the live format.

Change

  • parse_timestamp falls back to strptime("%Y-%m-%d %H:%M:%S %z") when fromisoformat fails.
  • Values without a time zone are still rejected.
  • Adds tests for the live format, a non-UTC offset, the Z form, and a value with no time zone.

Verification

  • pytest: 70 passed.
  • Live API, Python 3.10, keyword watch election, window 2026-09-28 to 2026-09-30: the current master fails with the error above; this branch writes a report with 5 articles.
  • Python 3.12 worked before and after.

Examples are not part of the PyPI package (find_packages(), no examples/__init__.py), so no release is needed.

🤖 Generated with Claude Code

…8-3.10

The Search API sends `published` as "2026-09-30 05:04:18 +0000".
datetime.fromisoformat only accepts that on Python 3.11+, so on 3.8-3.10
the company news monitor's live mode stopped at the first real article with
"news item published must be an RFC 3339 timestamp". The checked-in fixtures
use RFC 3339 ("...Z"), so the tests never saw the live format.

Fall back to strptime("%Y-%m-%d %H:%M:%S %z") and test both formats.
Verified against the live API on Python 3.10: before, the error above;
after, 5 matching articles in the report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Autumn-Atlas
Autumn-Atlas merged commit 00f34d7 into master Sep 30, 2026
5 checks passed
@Autumn-Atlas
Autumn-Atlas deleted the agent/monitor-parse-api-published branch September 30, 2026 07:29
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