danielfm / pybreaker

Python implementation of the Circuit Breaker pattern.
BSD 3-Clause "New" or "Revised" License
508 stars 74 forks source link

Convert datetime.utcnow -> datetime.now(UTC) #92

Open psi29a opened 2 months ago

psi29a commented 2 months ago

Removes deprecation warning and makes a timezone (UTC) aware datetime object.

Screenshot 2024-06-11 at 14 45 30
  /Users/psi29a/Workspace/backend/venv/lib/python3.12/site-packages/pybreaker/__init__.py:257: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    self._state_storage.opened_at = datetime.utcnow()

  /Users/psi29a/Workspace/backend/venv/lib/python3.12/site-packages/pybreaker/__init__.py:766: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    if opened_at and datetime.utcnow() < opened_at + timeout:
danielfm commented 1 month ago

@psi29a There is a lint error in this PR. You can fix that by putting the UTC first in the import list.

psi29a commented 1 month ago

Sure! :)