Skip to content

[docs] DTZ011: Docs confuse date with datetime #19384

@srittau

Description

@srittau

Summary

Currently, the docs says:

Python datetime objects can be naive or timezone-aware. While an aware object represents a specific moment in time, a naive object does not contain enough information to unambiguously locate itself relative to other datetime objects. Since this can lead to errors, it is recommended to always use timezone-aware objects.

datetime.date.today returns a naive datetime object. Instead, use datetime.datetime.now(tz=...).date() to create a timezone-aware object.

This is mentioning datetime objects multiple times, but this rule is about date objects. date objects can never be tz-aware (and are also not considered naïve, because that concept makes no sense for them). Overall I find the rule problematic conceptually, but the documentation should at least be accurate and don't mention datetime objects, or at least mention them in relation to date objects.

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationhelp wantedContributions especially welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions