Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ruff DTZ005 rule #11327

Merged
merged 10 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions other/gauss_easter.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ def gauss_easter(year: int) -> datetime:


if __name__ == "__main__":
for year in (1994, 2000, 2010, 2021, 2023):
tense = "will be" if year > datetime.now().year else "was"
for year in (1994, 2000, 2010, 2021, 2023, 2032, 2100):
tense = "will be" if year > datetime.now(tz=UTC).year else "was"
print(f"Easter in {year} {tense} {gauss_easter(year)}")
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
lint.ignore = [ # `ruff rule S101` for a description of that rule
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` -- FIX ME
"B905", # `zip()` without an explicit `strict=` parameter -- FIX ME
"DTZ005", # The use of `datetime.datetime.now()` without `tzinfo` argument is not allowed -- FIX ME
"E741", # Ambiguous variable name 'l' -- FIX ME
"EM101", # Exception must not use a string literal, assign to variable first
"EXE001", # Shebang is present but file is not executable" -- FIX ME
Expand Down
4 changes: 2 additions & 2 deletions web_programming/instagram_pic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import UTC, datetime

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

file_name = f"{datetime.now():%Y-%m-%d_%H:%M:%S}.jpg"
file_name = f"{datetime.now(tz=UTC).astimezone():%Y-%m-%d_%H:%M:%S}.jpg"
with open(file_name, "wb") as out_file:
out_file.write(image_data)
return f"Image downloaded and saved in the file {file_name}"
Expand Down
4 changes: 2 additions & 2 deletions web_programming/instagram_video.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import UTC, datetime

import requests

Expand All @@ -11,7 +11,7 @@ def download_video(url: str) -> bytes:

if __name__ == "__main__":
url = input("Enter Video/IGTV url: ").strip()
file_name = f"{datetime.now():%Y-%m-%d_%H:%M:%S}.mp4"
file_name = f"{datetime.now(tz=UTC).astimezone():%Y-%m-%d_%H:%M:%S}.mp4"
with open(file_name, "wb") as fp:
fp.write(download_video(url))
print(f"Done. Video saved to disk as {file_name}.")