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

(Sonar) Fixed finding: "Using timezone-aware "datetime" objects should be preferred over using "datetime.datetime.utcnow" and "datetime.datetime.utcfromtimestamp"" #455

Merged
Merged
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
6 changes: 3 additions & 3 deletions custom_components/xplora_watch/geocoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import collections
import os
import sys
from datetime import datetime
from datetime import timezone, datetime
from decimal import Decimal

import backoff
Expand Down Expand Up @@ -303,7 +303,7 @@ def _opencage_request(self, params):

if response.status_code in (402, 429):
# Rate limit exceeded
reset_time = datetime.utcfromtimestamp(response.json()["rate"]["reset"])
reset_time = datetime.fromtimestamp(response.json()["rate"]["reset"], tz=timezone.utc)

raise RateLimitExceededError(reset_to=int(response.json()["rate"]["limit"]), reset_time=reset_time)

Expand Down Expand Up @@ -346,7 +346,7 @@ async def _opencage_async_request(self, params):
if response.status in (402, 429):
# Rate limit exceeded

reset_time = datetime.utcfromtimestamp(response_json["rate"]["reset"])
reset_time = datetime.fromtimestamp(response_json["rate"]["reset"], tz=timezone.utc)

raise RateLimitExceededError(reset_to=int(response_json["rate"]["limit"]), reset_time=reset_time)

Expand Down
Loading