Skip to content

Commit dbe7f0b

Browse files
committed
Ruff
1 parent 08157c7 commit dbe7f0b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/utils/circuit_breaker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ def _get_failure_timestamps(self) -> List[datetime]:
4444
# If the log file does not exist, return an empty list
4545
if not self.log_file.exists():
4646
return []
47-
47+
4848
# If the log file exists, read and parse all timestamps
4949
try:
5050
with self.log_file.open("r") as f:
5151
timestamps = [datetime.fromisoformat(line.strip()) for line in f if line.strip()]
5252
return timestamps
53-
53+
5454
# If there is an error reading or parsing the log file, log the error and return an empty list
5555
except (IOError, ValueError) as e:
5656
logger.error(f"Error reading or parsing circuit breaker log file {self.log_file}: {e}")
@@ -105,7 +105,7 @@ def record_failure(self) -> None:
105105

106106
# Log the success
107107
logger.warning("Circuit breaker has recorded a failure.")
108-
108+
109109
# If there is an error appending the timestamp to the log file, log the error
110110
except IOError as e:
111111
logger.error(f"Failed to record failure to circuit breaker log {self.log_file}: {e}")

tests/test_circuit_breaker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Unit tests for the CircuitBreaker utility.
33
"""
4+
45
from datetime import datetime, timedelta
56
from unittest.mock import MagicMock, mock_open, patch
67

@@ -12,7 +13,7 @@
1213
@pytest.fixture
1314
def mock_path():
1415
"""Fixture to mock the Path object for file system interactions."""
15-
with patch("src.utils.circuit_breaker.Path") as mock_path_cls:
16+
with patch("src.utils.circuit_breaker.Path"):
1617
mock_instance = MagicMock()
1718
mock_instance.exists.return_value = False
1819
mock_instance.open = mock_open()
@@ -117,4 +118,4 @@ def test_reset_does_nothing_if_log_file_does_not_exist(breaker: CircuitBreaker,
117118
"""
118119
mock_path.exists.return_value = False
119120
breaker.reset()
120-
mock_path.unlink.assert_not_called()
121+
mock_path.unlink.assert_not_called()

0 commit comments

Comments
 (0)