Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit 81789cc

Browse files
committed
fixed lint
1 parent 379e77e commit 81789cc

9 files changed

Lines changed: 42 additions & 15 deletions

File tree

google/auth/_default.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
Implements application default credentials and project ID detection.
1818
"""
1919
from __future__ import annotations
20+
2021
import io
2122
import json
2223
import logging

tests/test__exponential_backoff.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import sys
16+
1617
if sys.version_info >= (3, 8):
1718
from unittest import mock
1819
from unittest.mock import AsyncMock
@@ -101,4 +102,4 @@ def test_minimum_total_attempts_async():
101102
_exponential_backoff.AsyncExponentialBackoff(total_attempts=0)
102103
with pytest.raises(exceptions.InvalidValue):
103104
_exponential_backoff.AsyncExponentialBackoff(total_attempts=-1)
104-
_exponential_backoff.AsyncExponentialBackoff(total_attempts=1)
105+
_exponential_backoff.AsyncExponentialBackoff(total_attempts=1)

tests/test_impersonated_credentials.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ def _test_id_token_helper(
11471147

11481148
# In Python 3.7, self might not be in call_args for autospecced methods
11491149
args = mock_authorizedsession_idtoken.call_args[0]
1150-
1150+
11511151
# Look for expected_url in args
11521152
assert expected_url in args
11531153

tests/transport/aio/test_aiohttp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import asyncio
1616
import sys
17+
1718
if sys.version_info >= (3, 8):
1819
from unittest.mock import Mock, patch, AsyncMock
1920
else:

tests_async/oauth2/test_credentials_async.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import os
1818
import pickle
1919
import sys
20+
2021
if sys.version_info >= (3, 8):
2122
from unittest import mock
2223
from unittest.mock import AsyncMock
@@ -63,7 +64,9 @@ def test_default_state(self):
6364
assert credentials.client_id == self.CLIENT_ID
6465
assert credentials.client_secret == self.CLIENT_SECRET
6566

66-
@mock.patch("google.oauth2._credentials_async.reauth.refresh_grant", new_callable=AsyncMock)
67+
@mock.patch(
68+
"google.oauth2._credentials_async.reauth.refresh_grant", new_callable=AsyncMock
69+
)
6770
@mock.patch(
6871
"google.auth._helpers.utcnow",
6972
return_value=datetime.datetime.min + _helpers.REFRESH_THRESHOLD,
@@ -125,7 +128,9 @@ async def test_refresh_no_refresh_token(self):
125128

126129
request.assert_not_called()
127130

128-
@mock.patch("google.oauth2._credentials_async.reauth.refresh_grant", new_callable=AsyncMock)
131+
@mock.patch(
132+
"google.oauth2._credentials_async.reauth.refresh_grant", new_callable=AsyncMock
133+
)
129134
@mock.patch(
130135
"google.auth._helpers.utcnow",
131136
return_value=datetime.datetime.min + _helpers.REFRESH_THRESHOLD,
@@ -189,7 +194,9 @@ async def test_credentials_with_scopes_requested_refresh_success(
189194
# expired.)
190195
assert creds.valid
191196

192-
@mock.patch("google.oauth2._credentials_async.reauth.refresh_grant", new_callable=AsyncMock)
197+
@mock.patch(
198+
"google.oauth2._credentials_async.reauth.refresh_grant", new_callable=AsyncMock
199+
)
193200
@mock.patch(
194201
"google.auth._helpers.utcnow",
195202
return_value=datetime.datetime.min + _helpers.REFRESH_THRESHOLD,
@@ -252,7 +259,9 @@ async def test_credentials_with_scopes_returned_refresh_success(
252259
# expired.)
253260
assert creds.valid
254261

255-
@mock.patch("google.oauth2._credentials_async.reauth.refresh_grant", new_callable=AsyncMock)
262+
@mock.patch(
263+
"google.oauth2._credentials_async.reauth.refresh_grant", new_callable=AsyncMock
264+
)
256265
@mock.patch(
257266
"google.auth._helpers.utcnow",
258267
return_value=datetime.datetime.min + _helpers.REFRESH_THRESHOLD,
@@ -471,7 +480,9 @@ def test_unpickle_old_credentials_pickle(self):
471480
assert credentials.quota_project_id is None
472481

473482
@mock.patch("google.oauth2._credentials_async.Credentials.apply", autospec=True)
474-
@mock.patch("google.oauth2._credentials_async.Credentials.refresh", new_callable=AsyncMock)
483+
@mock.patch(
484+
"google.oauth2._credentials_async.Credentials.refresh", new_callable=AsyncMock
485+
)
475486
@pytest.mark.asyncio
476487
async def test_before_request(self, refresh, apply):
477488
cred = self.make_credentials()

tests_async/oauth2/test_id_token.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import json
1616
import os
1717
import sys
18+
1819
if sys.version_info >= (3, 8):
1920
from unittest import mock
2021
from unittest.mock import AsyncMock
@@ -39,9 +40,9 @@ def make_request(status, data=None):
3940

4041
if data is not None:
4142
response.data = AsyncMock(spec=["__call__", "read"])
42-
43+
4344
async def get_content(*args, **kwargs):
44-
return json.dumps(data).encode("utf-8")
45+
return json.dumps(data).encode("utf-8")
4546

4647
response.data.read = AsyncMock(spec=["__call__"], side_effect=get_content)
4748
response.content = AsyncMock(spec=["__call__"], side_effect=get_content)

tests_async/oauth2/test_reauth_async.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import copy
1616
import sys
17+
1718
if sys.version_info >= (3, 8):
1819
from unittest import mock
1920
from unittest.mock import AsyncMock
@@ -220,7 +221,9 @@ async def test__obtain_rapt_unsupported_status():
220221
challenges_response = copy.deepcopy(CHALLENGES_RESPONSE_TEMPLATE)
221222
challenges_response["status"] = "STATUS_UNSPECIFIED"
222223
with mock.patch(
223-
"google.oauth2._reauth_async._get_challenges", new_callable=AsyncMock, return_value=challenges_response
224+
"google.oauth2._reauth_async._get_challenges",
225+
new_callable=AsyncMock,
226+
return_value=challenges_response,
224227
):
225228
with pytest.raises(exceptions.ReauthFailError) as excinfo:
226229
await _reauth_async._obtain_rapt(MOCK_REQUEST, "token", None)
@@ -261,7 +264,9 @@ async def test_get_rapt_token():
261264
return_value=("token", None, None, None),
262265
) as mock_refresh_grant:
263266
with mock.patch(
264-
"google.oauth2._reauth_async._obtain_rapt", new_callable=AsyncMock, return_value="new_rapt_token"
267+
"google.oauth2._reauth_async._obtain_rapt",
268+
new_callable=AsyncMock,
269+
return_value="new_rapt_token",
265270
) as mock_obtain_rapt:
266271
assert (
267272
await _reauth_async.get_rapt_token(
@@ -289,7 +294,8 @@ async def test_get_rapt_token():
289294
@pytest.mark.asyncio
290295
async def test_refresh_grant_failed():
291296
with mock.patch(
292-
"google.oauth2._client_async._token_endpoint_request_no_throw", new_callable=AsyncMock
297+
"google.oauth2._client_async._token_endpoint_request_no_throw",
298+
new_callable=AsyncMock,
293299
) as mock_token_request:
294300
mock_token_request.return_value = (False, {"error": "Bad request"}, True)
295301
with pytest.raises(exceptions.RefreshError) as excinfo:
@@ -321,14 +327,17 @@ async def test_refresh_grant_failed():
321327
@pytest.mark.asyncio
322328
async def test_refresh_grant_success():
323329
with mock.patch(
324-
"google.oauth2._client_async._token_endpoint_request_no_throw", new_callable=AsyncMock
330+
"google.oauth2._client_async._token_endpoint_request_no_throw",
331+
new_callable=AsyncMock,
325332
) as mock_token_request:
326333
mock_token_request.side_effect = [
327334
(False, {"error": "invalid_grant", "error_subtype": "rapt_required"}, True),
328335
(True, {"access_token": "access_token"}, None),
329336
]
330337
with mock.patch(
331-
"google.oauth2._reauth_async.get_rapt_token", new_callable=AsyncMock, return_value="new_rapt_token"
338+
"google.oauth2._reauth_async.get_rapt_token",
339+
new_callable=AsyncMock,
340+
return_value="new_rapt_token",
332341
):
333342
assert await _reauth_async.refresh_grant(
334343
MOCK_REQUEST,
@@ -349,7 +358,8 @@ async def test_refresh_grant_success():
349358
@pytest.mark.asyncio
350359
async def test_refresh_grant_reauth_refresh_disabled():
351360
with mock.patch(
352-
"google.oauth2._client_async._token_endpoint_request_no_throw", new_callable=AsyncMock
361+
"google.oauth2._client_async._token_endpoint_request_no_throw",
362+
new_callable=AsyncMock,
353363
) as mock_token_request:
354364
mock_token_request.side_effect = [
355365
(

tests_async/oauth2/test_service_account_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import datetime
1616
import sys
17+
1718
if sys.version_info >= (3, 8):
1819
from unittest import mock
1920
from unittest.mock import AsyncMock

tests_async/transport/test_aiohttp_requests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import sys
16+
1617
if sys.version_info >= (3, 8):
1718
from unittest import mock
1819
from unittest.mock import AsyncMock

0 commit comments

Comments
 (0)