diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs b/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs index 8f46629e29..963a07d757 100644 --- a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs +++ b/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs @@ -9,6 +9,28 @@ use crate::checkers::ast::Checker; use super::helpers; +/// ## What it does +/// Checks for `datetime` instantiations that lack a `tzinfo` argument. +/// +/// ## Why is this bad? +/// `datetime` objects are "naive" by default, in that they do not include +/// timezone information. By providing a `tzinfo`, a `datetime` can be made +/// timezone "aware". "Naive" objects are easy to understand, but ignore some +/// aspects of reality, which can lead to subtle bugs. +/// +/// ## Example +/// ```python +/// import datetime +/// +/// datetime.datetime(2000, 1, 1, 0, 0, 0) +/// ``` +/// +/// Use instead: +/// ```python +/// import datetime +/// +/// datetime.datetime(2000, 1, 1, 0, 0, 0, tzinfo=datetime.UTC) +/// ``` #[violation] pub struct CallDatetimeWithoutTzinfo;