Skip to content

Commit 980af88

Browse files
authored
Fix for check_types github action failing (#472)
Fixed the chekc_types failing
1 parent 328aeb5 commit 980af88

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/databricks/sql/auth/retry.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def get_backoff_time(self) -> float:
305305
:return:
306306
"""
307307

308-
current_attempt = self.stop_after_attempts_count - self.total
308+
current_attempt = self.stop_after_attempts_count - int(self.total or 0)
309309
proposed_backoff = (2**current_attempt) * self.delay_min
310310
if self.backoff_jitter != 0.0:
311311
proposed_backoff += random.random() * self.backoff_jitter

tests/unit/test_retry.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from databricks.sql.auth.retry import DatabricksRetryPolicy, RequestHistory, CommandType
66
from urllib3.exceptions import MaxRetryError
77

8+
89
class TestRetry:
910
@pytest.fixture()
1011
def retry_policy(self) -> DatabricksRetryPolicy:
@@ -33,7 +34,9 @@ def test_sleep__no_retry_after(self, t_mock, retry_policy, error_history):
3334
retry_policy.history = [error_history, error_history]
3435
retry_policy.sleep(HTTPResponse(status=503))
3536

36-
expected_backoff_time = self.calculate_backoff_time(0, retry_policy.delay_min, retry_policy.delay_max)
37+
expected_backoff_time = self.calculate_backoff_time(
38+
0, retry_policy.delay_min, retry_policy.delay_max
39+
)
3740
t_mock.assert_called_with(expected_backoff_time)
3841

3942
@patch("time.sleep")
@@ -50,10 +53,16 @@ def test_sleep__no_retry_after_header__multiple_retries(self, t_mock, retry_poli
5053

5154
expected_backoff_times = []
5255
for attempt in range(num_attempts):
53-
expected_backoff_times.append(self.calculate_backoff_time(attempt, retry_policy.delay_min, retry_policy.delay_max))
56+
expected_backoff_times.append(
57+
self.calculate_backoff_time(
58+
attempt, retry_policy.delay_min, retry_policy.delay_max
59+
)
60+
)
5461

5562
# Asserts if the sleep value was called in the expected order
56-
t_mock.assert_has_calls([call(expected_time) for expected_time in expected_backoff_times])
63+
t_mock.assert_has_calls(
64+
[call(expected_time) for expected_time in expected_backoff_times]
65+
)
5766

5867
@patch("time.sleep")
5968
def test_excessive_retry_attempts_error(self, t_mock, retry_policy):

0 commit comments

Comments
 (0)