Skip to content

Commit

Permalink
chore: Use logger.warning instead of deprecated logger.warn (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon authored Dec 23, 2024
1 parent c1966eb commit ad5db0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions tap_github/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def has_calls_remaining(self) -> bool:
self.claim_token()
if self.token is None:
if self.logger:
self.logger.warn("GitHub app token refresh failed.")
self.logger.warning("GitHub app token refresh failed.")
return False
else:
if self.logger:
Expand Down Expand Up @@ -278,7 +278,7 @@ def prepare_tokens(self) -> list[TokenManager]:
if token_manager.is_valid_token():
personal_token_managers.append(token_manager)
else:
logging.warn("A token was dismissed.")
logging.warning("A token was dismissed.")

# Parse App level private keys and generate tokens
# To simplify settings, we use a single env-key formatted as follows:
Expand Down Expand Up @@ -308,7 +308,7 @@ def prepare_tokens(self) -> list[TokenManager]:
if app_token_manager.is_valid_token():
app_token_managers.append(app_token_manager)
except ValueError as e:
self.logger.warn(
self.logger.warning(
f"An error was thrown while preparing an app token: {e}"
)

Expand Down
12 changes: 6 additions & 6 deletions tap_github/tests/test_authenticator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re
from datetime import datetime, timedelta
from unittest.mock import MagicMock, patch
from unittest.mock import MagicMock, call, patch

import pytest
import requests
Expand Down Expand Up @@ -215,10 +215,10 @@ def test_has_calls_remaining_logs_warning_if_token_regeneration_fails(self):

mock_is_valid.return_value = False
assert not token_manager.has_calls_remaining()
token_manager.logger.warn.assert_called_once()
assert (
"GitHub app token refresh failed."
in token_manager.logger.warn.call_args[0][0]
assert isinstance(token_manager.logger.warning, MagicMock)
token_manager.logger.warning.assert_has_calls(
[call("GitHub app token refresh failed.")],
any_order=True,
)

def test_has_calls_remaining_succeeds_if_token_new_and_never_used(self):
Expand Down Expand Up @@ -537,7 +537,7 @@ def test_handle_error_if_app_key_invalid(self, mock_stream):
auth = GitHubTokenAuthenticator(stream=mock_stream)
auth.prepare_tokens()

mock_stream.logger.warn.assert_called_with(
mock_stream.logger.warning.assert_called_with(
"An error was thrown while preparing an app token: Invalid key format"
)

Expand Down

0 comments on commit ad5db0a

Please sign in to comment.