diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_fromtimestamp.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_fromtimestamp.rs index 97b76d57fca8b..8ea11704b2d9c 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_fromtimestamp.rs +++ b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_fromtimestamp.rs @@ -11,15 +11,15 @@ use crate::checkers::ast::Checker; /// Checks for usage of `datetime.date.fromtimestamp()`. /// /// ## Why is this bad? -/// Python datetime objects can be naive or timezone-aware. While an aware +/// Python date objects are naive, that is, not 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.fromtimestamp(ts)` returns a naive datetime object. -/// Instead, use `datetime.datetime.fromtimestamp(ts, tz=...)` to create a -/// timezone-aware object. +/// `datetime.date.fromtimestamp(ts)` returns a naive date object. +/// Instead, use `datetime.datetime.fromtimestamp(ts, tz=...).date()` to +/// create a timezone-aware datetime object and retrieve its date component. /// /// ## Example /// ```python @@ -32,14 +32,14 @@ use crate::checkers::ast::Checker; /// ```python /// import datetime /// -/// datetime.datetime.fromtimestamp(946684800, tz=datetime.timezone.utc) +/// datetime.datetime.fromtimestamp(946684800, tz=datetime.timezone.utc).date() /// ``` /// /// Or, for Python 3.11 and later: /// ```python /// import datetime /// -/// datetime.datetime.fromtimestamp(946684800, tz=datetime.UTC) +/// datetime.datetime.fromtimestamp(946684800, tz=datetime.UTC).date() /// ``` /// /// ## References diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_today.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_today.rs index 533d5bf0e3ce6..1010fb6c17fcf 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_today.rs +++ b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_today.rs @@ -11,14 +11,15 @@ use crate::checkers::ast::Checker; /// Checks for usage of `datetime.date.today()`. /// /// ## Why is this bad? -/// Python datetime objects can be naive or timezone-aware. While an aware +/// Python date objects are naive, that is, not 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. +/// `datetime.date.today` returns a naive date object without taking timezones +/// into account. Instead, use `datetime.datetime.now(tz=...).date()` to +/// create a timezone-aware object and retrieve its date component. /// /// ## Example /// ```python diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_today.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_today.rs index f748b8d832a48..c902d72200604 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_today.rs +++ b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_today.rs @@ -42,6 +42,9 @@ use crate::rules::flake8_datetimez::helpers; /// /// datetime.datetime.now(tz=datetime.UTC) /// ``` +/// +/// ## References +/// - [Python documentation: Aware and Naive Objects](https://docs.python.org/3/library/datetime.html#aware-and-naive-objects) #[derive(ViolationMetadata)] pub(crate) struct CallDatetimeToday; diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs index d4c53cf324ec2..7fe640462fb43 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs +++ b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs @@ -41,6 +41,9 @@ use crate::rules::flake8_datetimez::helpers::{self, DatetimeModuleAntipattern}; /// /// datetime.datetime(2000, 1, 1, 0, 0, 0, tzinfo=datetime.UTC) /// ``` +/// +/// ## References +/// - [Python documentation: Aware and Naive Objects](https://docs.python.org/3/library/datetime.html#aware-and-naive-objects) #[derive(ViolationMetadata)] pub(crate) struct CallDatetimeWithoutTzinfo(DatetimeModuleAntipattern); diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/rules/datetime_min_max.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/datetime_min_max.rs index a55a91f762247..dafa96df78d0b 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/rules/datetime_min_max.rs +++ b/crates/ruff_linter/src/rules/flake8_datetimez/rules/datetime_min_max.rs @@ -38,6 +38,9 @@ use crate::checkers::ast::Checker; /// /// datetime.datetime.max.replace(tzinfo=datetime.UTC) /// ``` +/// +/// ## References +/// - [Python documentation: Aware and Naive Objects](https://docs.python.org/3/library/datetime.html#aware-and-naive-objects) #[derive(ViolationMetadata)] pub(crate) struct DatetimeMinMax { min_max: MinMax,