Skip to content

Commit

Permalink
Don't suggest invalid syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed Mar 27, 2024
1 parent 7beb878 commit 23e8a23
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::checkers::ast::Checker;
/// always use timezone-aware objects.
///
/// `datetime.date.fromtimestamp(ts)` returns a naive datetime object.
/// Instead, use `datetime.datetime.fromtimestamp(ts, tz=)` to return a
/// Instead, use `datetime.datetime.fromtimestamp(ts, tz=...)` to return a
/// timezone-aware object.
///
/// ## Example
Expand Down Expand Up @@ -54,7 +54,7 @@ impl Violation for CallDateFromtimestamp {
}

fn fix_title(&self) -> Option<String> {
Some("Use `datetime.datetime.fromtimestamp(ts, tz=).date()` instead".to_string())
Some("Use `datetime.datetime.fromtimestamp(ts, tz=...).date()` instead".to_string())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::checkers::ast::Checker;
/// always use timezone-aware objects.
///
/// `datetime.date.today` returns a naive datetime object. Instead, use
/// `datetime.datetime.now(tz=).date()` to return a timezone-aware object.
/// `datetime.datetime.now(tz=...).date()` to return a timezone-aware object.
///
/// ## Example
/// ```python
Expand Down Expand Up @@ -53,7 +53,7 @@ impl Violation for CallDateToday {
}

fn fix_title(&self) -> Option<String> {
Some("Use `datetime.datetime.now(tz=).date()` instead".to_string())
Some("Use `datetime.datetime.now(tz=...).date()` instead".to_string())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use super::helpers::{self, DatetimeModuleAntipattern};
///
/// `datetime.datetime.fromtimestamp(ts)` or
/// `datetime.datetime.fromtimestampe(ts, tz=None)` returns a naive datetime
/// object. Instead, use `datetime.datetime.fromtimestamp(ts, tz=)` to return a
/// object. Instead, use `datetime.datetime.fromtimestamp(ts, tz=...)` to return a
/// timezone-aware object.
///
/// ## Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use super::helpers::{self, DatetimeModuleAntipattern};
/// always use timezone-aware objects.
///
/// `datetime.datetime.now()` or `datetime.datetime.now(tz=None)` returns a naive
/// datetime object. Instead, use `datetime.datetime.now(tz=)` to return a
/// datetime object. Instead, use `datetime.datetime.now(tz=<timezone>)` to return a
/// timezone-aware object.
///
/// ## Example
Expand Down Expand Up @@ -54,7 +54,7 @@ impl Violation for CallDatetimeNowWithoutTzinfo {
let CallDatetimeNowWithoutTzinfo(antipattern) = self;
match antipattern {
DatetimeModuleAntipattern::NoTzArgumentPassed => {
format!("`datetime.datetime.now()` called without a `tz=` argument")
format!("`datetime.datetime.now()` called without a `tz` argument")
}
DatetimeModuleAntipattern::NonePassedToTzArgument => {
format!("`tz=None` passed to `datetime.datetime.now()`")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use super::helpers::DatetimeModuleAntipattern;
/// always use timezone-aware objects.
///
/// `datetime.datetime.strptime()` without `%z` returns a naive datetime
/// object. Follow it with `.replace(tzinfo=)` or `.astimezone()`.
/// object. Follow it with `.replace(tzinfo=<timezone>)` or `.astimezone()`.
///
/// ## Example
/// ```python
Expand All @@ -28,7 +28,7 @@ use super::helpers::DatetimeModuleAntipattern;
/// datetime.datetime.strptime("2022/01/31", "%Y/%m/%d")
/// ```
///
/// Instead, use `.replace(tzinfo=)`:
/// Instead, use `.replace(tzinfo=<timezone>)`:
/// ```python
/// import datetime
///
Expand Down Expand Up @@ -71,11 +71,12 @@ impl Violation for CallDatetimeStrptimeWithoutZone {
let CallDatetimeStrptimeWithoutZone(antipattern) = self;
match antipattern {
DatetimeModuleAntipattern::NoTzArgumentPassed => Some(
"Call `.replace(tzinfo=)` or `.astimezone()` to convert to an aware datetime"
"Call `.replace(tzinfo=<timezone>)` or `.astimezone()` \
to convert to an aware datetime"
.to_string(),
),
DatetimeModuleAntipattern::NonePassedToTzArgument => {
Some("Pass a `datetime.timezone` object to `tzinfo=`".to_string())
Some("Pass a `datetime.timezone` object to `tzinfo`".to_string())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use super::helpers;
/// time, unlike "naive" objects.
///
/// `datetime.datetime.today()` creates a "naive" object; instead, use
/// `datetime.datetime.now(tz=)` to create a timezone-aware object.
/// `datetime.datetime.now(tz=...)` to create a timezone-aware object.
///
/// ## Example
/// ```python
Expand Down Expand Up @@ -52,7 +52,7 @@ impl Violation for CallDatetimeToday {
}

fn fix_title(&self) -> Option<String> {
Some("Use `datetime.datetime.now(tz=)` instead".to_string())
Some("Use `datetime.datetime.now(tz=...)` instead".to_string())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ use super::helpers;
/// datetime objects. Since this can lead to errors, it is recommended to
/// always use timezone-aware objects.
///
/// `datetime.datetime.utcfromtimestamp()` or
/// `datetime.datetime.utcfromtimestamp(tz=None)` returns a naive datetime
/// object; instead, use `datetime.datetime.fromtimestamp(ts, tz=)` to return a
/// timezone-aware object.
/// `datetime.datetime.utcfromtimestamp()` returns a naive datetime
/// object; instead, use `datetime.datetime.fromtimestamp(ts, tz=...)`
/// to return a timezone-aware object.
///
/// ## Example
/// ```python
Expand Down Expand Up @@ -57,7 +56,7 @@ impl Violation for CallDatetimeUtcfromtimestamp {
}

fn fix_title(&self) -> Option<String> {
Some("Use `datetime.datetime.fromtimestamp(ts, tz=)` instead".to_string())
Some("Use `datetime.datetime.fromtimestamp(ts, tz=...)` instead".to_string())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use super::helpers;
/// always use timezone-aware objects.
///
/// `datetime.datetime.utcnow()` returns a naive datetime object; instead, use
/// `datetime.datetime.now(tz=)` to return a timezone-aware object.
/// `datetime.datetime.now(tz=...)` to return a timezone-aware object.
///
/// ## Example
/// ```python
Expand Down Expand Up @@ -55,7 +55,7 @@ impl Violation for CallDatetimeUtcnow {
}

fn fix_title(&self) -> Option<String> {
Some("Use `datetime.datetime.now(tz=)` instead".to_string())
Some("Use `datetime.datetime.now(tz=...)` instead".to_string())
}
}

Expand Down

0 comments on commit 23e8a23

Please sign in to comment.