fix(examples): parse live API published timestamps on Python 3.8-3.10 - #13
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Search API sends
publishedas2026-09-30 05:04:18 +0000, with a space before the offset.datetime.fromisoformataccepts 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:The fixtures use RFC 3339 (
2026-08-05T07:30:00Z), so the tests never exercised the live format.Change
parse_timestampfalls back tostrptime("%Y-%m-%d %H:%M:%S %z")whenfromisoformatfails.Zform, and a value with no time zone.Verification
pytest: 70 passed.election, window 2026-09-28 to 2026-09-30: the currentmasterfails with the error above; this branch writes a report with 5 articles.Examples are not part of the PyPI package (
find_packages(), noexamples/__init__.py), so no release is needed.🤖 Generated with Claude Code