Skip to content

Commit

Permalink
Fix inconsistency due to rounding in CachedResponse.expires_unix prop…
Browse files Browse the repository at this point in the history
…erty
  • Loading branch information
JWCook committed Mar 19, 2024
1 parent 320d5b8 commit b1d1740
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# History

## 1.2.1 (2024-02-xx)
## Unreleased

🪲 **Bugfixes:**
* Fix `normalize_headers` not accepting header values in bytes
* Fix inconsistency due to rounding in `CachedResponse.expires_unix` property

## 1.2.0 (2024-02-17)

Expand Down
6 changes: 3 additions & 3 deletions requests_cache/models/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from datetime import datetime, timedelta
from logging import getLogger
from time import time
from typing import TYPE_CHECKING, Dict, List, Optional, Union

import attr
Expand Down Expand Up @@ -144,8 +143,9 @@ def expires_delta(self) -> Optional[int]:
@property
def expires_unix(self) -> Optional[int]:
"""Get expiration time as a Unix timestamp"""
seconds = self.expires_delta
return round(time() + seconds) if seconds is not None else None
if self.expires is None:
return None
return round(self.expires.timestamp())

@property
def from_cache(self) -> bool:
Expand Down

0 comments on commit b1d1740

Please sign in to comment.