Skip to content

[flake8-datetimez] Clarify naming guidance for datetime.today (DTZ002) - #26658

Merged
ntBre merged 2 commits into
astral-sh:mainfrom
Joosboy:docs-ruff23392-dtz002
Jul 9, 2026
Merged

[flake8-datetimez] Clarify naming guidance for datetime.today (DTZ002)#26658
ntBre merged 2 commits into
astral-sh:mainfrom
Joosboy:docs-ruff23392-dtz002

Conversation

@Joosboy

@Joosboy Joosboy commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

This updates the DTZ002 documentation to clarify the datetime.today() naming confusion raised in #23392.

  • Notes that datetime.datetime.today() is named like a date helper, but it returns a local datetime.
  • Keeps the existing guidance to use timezone-aware datetime.now(...) when you need an aware timestamp.

Why this changed

The code behavior is already correct; this is a docs-only improvement to make the rule intent easier to understand.

Test Plan

  • cargo dev generate-docs
  • cargo fmt --check --all
  • PATH="$PWD/target/debug:$PATH" uv run --only-group dev --locked python scripts/check_docs_formatted.py

@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre July 9, 2026 09:12

@ntBre ntBre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I just moved the new paragraph after the existing ones.

@ntBre ntBre changed the title [ruff] Clarify DTZ002 naming guidance for datetime.today [flake8-datetimez] Clarify naming guidance for datetime.today (DTZ002) Jul 9, 2026
@ntBre ntBre added the documentation Improvements or additions to documentation label Jul 9, 2026
@ntBre ntBre linked an issue Jul 9, 2026 that may be closed by this pull request
@astral-sh-bot

astral-sh-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre
ntBre merged commit 32bb6cf into astral-sh:main Jul 9, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disallow datetime.today() in favor of datetime.now()

2 participants