---
source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs
---
DTZ007.py:4:1: DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z
  |
3 | # bad format
4 | datetime.datetime.strptime("something", "%H:%M:%S%Z")
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007
5 | 
6 | # no replace or astimezone
  |
  = help: Call `.replace(tzinfo=<timezone>)` or `.astimezone()` to convert to an aware datetime

DTZ007.py:7:1: DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z
  |
6 | # no replace or astimezone
7 | datetime.datetime.strptime("something", "something")
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007
8 | 
9 | # wrong replace
  |
  = help: Call `.replace(tzinfo=<timezone>)` or `.astimezone()` to convert to an aware datetime

DTZ007.py:10:1: DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z
   |
 9 | # wrong replace
10 | datetime.datetime.strptime("something", "something").replace(hour=1)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007
11 | 
12 | # none replace
   |
   = help: Call `.replace(tzinfo=<timezone>)` or `.astimezone()` to convert to an aware datetime

DTZ007.py:13:1: DTZ007 `datetime.datetime.strptime(...).replace(tz=None)` used
   |
12 | # none replace
13 | datetime.datetime.strptime("something", "something").replace(tzinfo=None)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007
14 | 
15 | # OK
   |
   = help: Pass a `datetime.timezone` object to the `tzinfo` parameter

DTZ007.py:35:1: DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z
   |
34 | # no replace orastimezone unqualified
35 | datetime.strptime("something", "something")
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007
36 | 
37 | # F-strings
   |
   = help: Call `.replace(tzinfo=<timezone>)` or `.astimezone()` to convert to an aware datetime
