Enable ruff DTZ005 rule (#11327) · foo123/The-Algorithms-Python@b5cb1fb · GitHub
Skip to content

Commit b5cb1fb

Browse files
Enable ruff DTZ005 rule (TheAlgorithms#11327)
* Enable ruff DTZ005 rule * Fix other/gauss_easter.py * Fix * Fix web_programming/instagram_pic.py * Fix web_programming/instagram_video.py * Apply suggestions from code review * Update instagram_pic.py * datetime.now(tz=UTC).astimezone() * .astimezone() * Fix --------- Co-authored-by: Christian Clauss <cclauss@me.com>
1 parent ead5431 commit b5cb1fb

4 files changed

Lines changed: 6 additions & 7 deletions

File tree

other/gauss_easter.py

Lines changed: 2 additions & 2 deletions

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
lint.ignore = [ # `ruff rule S101` for a description of that rule
33
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` -- FIX ME
44
"B905", # `zip()` without an explicit `strict=` parameter -- FIX ME
5-
"DTZ005", # The use of `datetime.datetime.now()` without `tzinfo` argument is not allowed -- FIX ME
65
"E741", # Ambiguous variable name 'l' -- FIX ME
76
"EM101", # Exception must not use a string literal, assign to variable first
87
"EXE001", # Shebang is present but file is not executable" -- FIX ME

web_programming/instagram_pic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import datetime
1+
from datetime import UTC, datetime
22

33
import requests
44
from bs4 import BeautifulSoup
@@ -36,7 +36,7 @@ def download_image(url: str) -> str:
3636
if not image_data:
3737
return f"Failed to download the image from {image_url}."
3838

39-
file_name = f"{datetime.now():%Y-%m-%d_%H:%M:%S}.jpg"
39+
file_name = f"{datetime.now(tz=UTC).astimezone():%Y-%m-%d_%H:%M:%S}.jpg"
4040
with open(file_name, "wb") as out_file:
4141
out_file.write(image_data)
4242
return f"Image downloaded and saved in the file {file_name}"

web_programming/instagram_video.py

Lines changed: 2 additions & 2 deletions

0 commit comments

Comments
 (0)