mirror of https://github.com/astral-sh/ruff
feat: add more DTZ fix suggestions in messages (#2274)
This commit is contained in:
parent
8149c8cbc4
commit
221b87332c
10
README.md
10
README.md
|
|
@ -938,14 +938,14 @@ For more, see [flake8-datetimez](https://pypi.org/project/flake8-datetimez/) on
|
||||||
| Code | Name | Message | Fix |
|
| Code | Name | Message | Fix |
|
||||||
| ---- | ---- | ------- | --- |
|
| ---- | ---- | ------- | --- |
|
||||||
| DTZ001 | call-datetime-without-tzinfo | The use of `datetime.datetime()` without `tzinfo` argument is not allowed | |
|
| DTZ001 | call-datetime-without-tzinfo | The use of `datetime.datetime()` without `tzinfo` argument is not allowed | |
|
||||||
| DTZ002 | call-datetime-today | The use of `datetime.datetime.today()` is not allowed | |
|
| DTZ002 | call-datetime-today | The use of `datetime.datetime.today()` is not allowed, use `datetime.datetime.now(tz=)` instead | |
|
||||||
| DTZ003 | call-datetime-utcnow | The use of `datetime.datetime.utcnow()` is not allowed | |
|
| DTZ003 | call-datetime-utcnow | The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead | |
|
||||||
| DTZ004 | call-datetime-utcfromtimestamp | The use of `datetime.datetime.utcfromtimestamp()` is not allowed | |
|
| DTZ004 | call-datetime-utcfromtimestamp | The use of `datetime.datetime.utcfromtimestamp()` is not allowed, use `datetime.datetime.fromtimestamp(ts, tz=)` instead | |
|
||||||
| DTZ005 | call-datetime-now-without-tzinfo | The use of `datetime.datetime.now()` without `tz` argument is not allowed | |
|
| DTZ005 | call-datetime-now-without-tzinfo | The use of `datetime.datetime.now()` without `tz` argument is not allowed | |
|
||||||
| DTZ006 | call-datetime-fromtimestamp | The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed | |
|
| DTZ006 | call-datetime-fromtimestamp | The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed | |
|
||||||
| DTZ007 | call-datetime-strptime-without-zone | The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` | |
|
| DTZ007 | call-datetime-strptime-without-zone | The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` | |
|
||||||
| DTZ011 | call-date-today | The use of `datetime.date.today()` is not allowed. | |
|
| DTZ011 | call-date-today | The use of `datetime.date.today()` is not allowed, use `datetime.datetime.now(tz=).date()` instead | |
|
||||||
| DTZ012 | call-date-fromtimestamp | The use of `datetime.date.fromtimestamp()` is not allowed | |
|
| DTZ012 | call-date-fromtimestamp | The use of `datetime.date.fromtimestamp()` is not allowed, use `datetime.datetime.fromtimestamp(ts, tz=).date()` instead | |
|
||||||
|
|
||||||
### flake8-debugger (T10)
|
### flake8-debugger (T10)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4061,7 +4061,10 @@ define_violation!(
|
||||||
impl Violation for CallDatetimeToday {
|
impl Violation for CallDatetimeToday {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
fn message(&self) -> String {
|
fn message(&self) -> String {
|
||||||
format!("The use of `datetime.datetime.today()` is not allowed")
|
format!(
|
||||||
|
"The use of `datetime.datetime.today()` is not allowed, use \
|
||||||
|
`datetime.datetime.now(tz=)` instead"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4071,7 +4074,10 @@ define_violation!(
|
||||||
impl Violation for CallDatetimeUtcnow {
|
impl Violation for CallDatetimeUtcnow {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
fn message(&self) -> String {
|
fn message(&self) -> String {
|
||||||
format!("The use of `datetime.datetime.utcnow()` is not allowed")
|
format!(
|
||||||
|
"The use of `datetime.datetime.utcnow()` is not allowed, use \
|
||||||
|
`datetime.datetime.now(tz=)` instead"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4081,7 +4087,10 @@ define_violation!(
|
||||||
impl Violation for CallDatetimeUtcfromtimestamp {
|
impl Violation for CallDatetimeUtcfromtimestamp {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
fn message(&self) -> String {
|
fn message(&self) -> String {
|
||||||
format!("The use of `datetime.datetime.utcfromtimestamp()` is not allowed")
|
format!(
|
||||||
|
"The use of `datetime.datetime.utcfromtimestamp()` is not allowed, use \
|
||||||
|
`datetime.datetime.fromtimestamp(ts, tz=)` instead"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4126,7 +4135,10 @@ define_violation!(
|
||||||
impl Violation for CallDateToday {
|
impl Violation for CallDateToday {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
fn message(&self) -> String {
|
fn message(&self) -> String {
|
||||||
format!("The use of `datetime.date.today()` is not allowed.")
|
format!(
|
||||||
|
"The use of `datetime.date.today()` is not allowed, use \
|
||||||
|
`datetime.datetime.now(tz=).date()` instead"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4136,7 +4148,10 @@ define_violation!(
|
||||||
impl Violation for CallDateFromtimestamp {
|
impl Violation for CallDateFromtimestamp {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
fn message(&self) -> String {
|
fn message(&self) -> String {
|
||||||
format!("The use of `datetime.date.fromtimestamp()` is not allowed")
|
format!(
|
||||||
|
"The use of `datetime.date.fromtimestamp()` is not allowed, use \
|
||||||
|
`datetime.datetime.fromtimestamp(ts, tz=).date()` instead"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue