Skip to content

Conversation

ageorgou
Copy link
Contributor

@ageorgou ageorgou commented Oct 8, 2025

Summary

Resolves #19384.

  • Distinguishes more clearly between date and datetime objects.
  • Uniformly links to the relevant Python docs from rules in this category.

I've tried to be clearer, but there's still a contradiction in the rules as written: we say "use timezone-aware objects", but dates are inherently timezone-naive.

Also, the full docs don't always match the error message: for instance, in DTZ012, the example says to use:

datetime.datetime.fromtimestamp(946684800, tz=datetime.UTC)

while fix_title returns "Use datetime.datetime.fromtimestamp(ts, tz=...)**.date()** instead".
I have left this as it was for now.

Test Plan

Ran mkdocs locally and inspected result.

Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thank you, this looks like a nice improvement! Would you mind fixing the CI failure? It looks like you just need to run cargo fmt.

I think it would also make sense to update the examples to match fix_title, at least for DTZ012 as you pointed out.

@ntBre ntBre added the documentation Improvements or additions to documentation label Oct 9, 2025
@ntBre ntBre changed the title [flake8-datetimez] Clarify docs for some flake8-datetimez rules [flake8-datetimez] Clarify docs for several rules Oct 9, 2025
Copy link
Contributor

github-actions bot commented Oct 9, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ageorgou
Copy link
Contributor Author

ageorgou commented Oct 9, 2025

Updated, let me know if that's what you had in mind.

Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Perfect, thanks again!

@ntBre ntBre enabled auto-merge (squash) October 10, 2025 13:00
@ntBre ntBre merged commit bbd3856 into astral-sh:main Oct 10, 2025
36 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.

[docs] DTZ011: Docs confuse date with datetime

2 participants