Skip to content

Commit 27cc46f

Browse files
committed
Metadata API: Refactor strptime call
This makes flake8-datetimez happier but has no effect on the result: DTZ007 The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone() Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent d86f8ad commit 27cc46f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

tuf/api/_payload.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ def _common_fields_from_dict(
181181
# Convert 'expires' TUF metadata string to a datetime object, which is
182182
# what the constructor expects and what we store. The inverse operation
183183
# is implemented in '_common_fields_to_dict'.
184-
expires = datetime.strptime(expires_str, "%Y-%m-%dT%H:%M:%SZ")
185-
expires = expires.replace(tzinfo=timezone.utc)
184+
expires = datetime.strptime(expires_str, "%Y-%m-%dT%H:%M:%SZ").replace(
185+
tzinfo=timezone.utc
186+
)
186187

187188
return version, spec_version, expires
188189

0 commit comments

Comments
 (0)