Skip to content

Commit

Permalink
call-datetime-without-tzinfo comment (#6105)
Browse files Browse the repository at this point in the history
## Summary

Updated doc comment for `call_datetime_without_tzinfo.rs`. Online docs
also benefit from this update.

## Test Plan

Checked docs via
[mkdocs](https://github.com/astral-sh/ruff/blob/389fe13c934fe73679474006412b1eded4a2cad0/CONTRIBUTING.md?plain=1#L267-L296)
  • Loading branch information
arembridge authored Jul 26, 2023
1 parent ffdd653 commit d04367a
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit d04367a

Please sign in to comment.