mirror of
https://github.com/probberechts/soccerdata.git
synced 2026-04-25 18:15:58 +03:00
[GH-ISSUE #599] [WhoScored] TypeError in DateTime Comparison, DateTime no longer tz-aware #111
Labels
No labels
ESPN
FBref
FotMob
MatchHistory
SoFIFA
Sofascore
WhoScored
WhoScored
bug
build
common
dependencies
discussion
documentation
duplicate
enhancement
good first issue
invalid
performance
pull-request
question
question
removal
understat
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/soccerdata#111
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ds-oliver on GitHub (May 28, 2024).
Original GitHub issue: https://github.com/probberechts/soccerdata/issues/599
Issue: TypeError in DateTime Comparison After Update
Description
After updating the
soccerdatarepository, I encountered aTypeErrorwhen comparing datetime objects in my script. The error suggests an invalid comparison between tz-naive and tz-aware datetime-like objects. This issue did not occur before the update.Error Traceback
Steps to Reproduce
soccerdatarepository.TypeErrorduring the comparison of datetime objects.Expected Behavior
The script should successfully compare datetime objects without raising a
TypeError.Environment
Additional Information
Suggested Fix
Ensure the datetime objects being compared are either both tz-naive or both tz-aware. Possible solution is to convert
schedule["date"]to tz-naive before comparison.Thank you for your assistance.
@probberechts commented on GitHub (May 29, 2024):
Although I didn't change this intentionally, I prefer tz-aware datetime objects. Naive datetime objects are Python-only abstractions that don't identify anything in the real world; they're highly error prone and sort of work properly only if used in a limited scope where you work in a specific time zone.
Is it correct that the
schedule["date"] <= datetime.now()comparison is in your script? Then I would suggest usingdatatime.utcnow()instead.