Repository navigation
Enable ruff DTZ002, DTZ006 and DTZ011 (second wave for #13412) - #14602
gauranshahuja wants to merge 1 commit into
Conversation
|
Thanks for the PR, @gauranshahuja! @RayBB is assigned to this PR and currently has:
PR triage checklist (maintainers / Pierre)
Note This comment was automatically generated by Pierre, Open Library's PR first-touch assistant, on behalf of @mekarpeles. This is NOT a code review or sign-off. |
openlibrary-bot
left a comment
There was a problem hiding this comment.
No issues found on 85b4bd6.
🎫 Linked issues 🔶: #13412 🔶
#13412 - Partially compliant
Compliant requirements:
- Enables DTZ002, DTZ006 and DTZ011 (DTZ003/DTZ004 were already enabled) and fixes every call site they flag
Non-compliant requirements:
- The blanket "DTZ" selector itself is still commented out in pyproject.toml; only a subset of DTZ rules (002, 003, 004, 006, 011) is enabled, not the full flake8-datetimez rule family (e.g. DTZ001, DTZ005, DTZ007, DTZ012 remain off)
Requires further human verification:
- Whether pre-commit/CI passes cleanly with the newly enabled rules across the whole repo
A maintainer will review this PR next · How this bot works
85b4bd6 to
c4f1771
Compare
openlibrary-bot
left a comment
There was a problem hiding this comment.
No issues found on c4f1771.
🎫 Linked issues 🔶: #13412 🔶
#13412 - Partially compliant
Compliant requirements:
- Enables DTZ002 (datetime.today()), DTZ006 (fromtimestamp() without tz), and DTZ011 (date.today()), alongside the already-enabled DTZ003/DTZ004
- Fixes every call site in the tree that would otherwise violate the newly enabled rules
Non-compliant requirements:
- The full "DTZ" rule group is still commented out in pyproject.toml; rules like DTZ001, DTZ005, DTZ007, DTZ012 remain disabled
Requires further human verification:
- Whether pre-commit/CI actually passes with these rules enabled
- Whether the targeted pytest warnings are gone
A maintainer will review this PR next · How this bot works
|
@cclauss would you be willing to take a look at this one? |
Part of #13412. This is the second DTZ wave, following #14243, which covered DTZ003 and DTZ004.
What changed
This PR selects three more flake8-datetimez rules in
pyproject.tomland fixes the 21 call sites they flag:date.today()datetime.now(UTC).date()datetime.today()datetime.now(UTC).replace(tzinfo=None)datetime.fromtimestamp(ts)datetime.fromtimestamp(ts, tz=UTC), plus.replace(tzinfo=None)where the result is stored or compared as a datetimeValues that were naive datetimes stay naive, the same way #14243 kept them, so nothing stored or compared changes type. Values that were
dateobjects are stilldateobjects.Behaviour
Each of these calls used the process's local time zone. The repo's Docker and compose files do not set
TZ, so the containers they build already run in UTC, and these calls return the same values there as before. The difference shows up only on a machine whose local time zone is not UTC: there, "today" now means the UTC date.@cclauss: RayBB suggested I check with you before going further. Two questions:
Testing
ruff check(0.17.4, the version pinned in.pre-commit-config.yaml): no findings in this branch that master doesn't already have. DTZ002, DTZ006 and DTZ011 now report 0.ruff format --checkon the changed files passes.fcntl), so the branch adds no new failures.tests/fastapi/test_tasks_stats.pyand theutils/dateutil.pydoctests pass.