Skip to content

Commit ce124b0

Browse files
authored
chore: remove logging for async requests (#1698)
* chore: remove logging for async requests * change Dict to Mapping * fix mypy and lint issues * address PR feedback * link issue
1 parent 4fb93ff commit ce124b0

File tree

7 files changed

+14
-12
lines changed

7 files changed

+14
-12
lines changed

google/auth/_helpers.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
import hashlib
2222
import logging
2323
import sys
24-
from typing import Optional, Dict, Any
24+
from typing import Any, Mapping, Optional
2525
import urllib
2626

2727
from google.auth import exceptions
2828

2929
try:
30-
from google.api_core import client_logging
30+
# TODO(https://github.com/googleapis/python-api-core/issues/813): Remove `# type: ignore` when
31+
# `google-api-core` type hints issue is resolved.
32+
from google.api_core import client_logging # type: ignore # noqa: F401
3133

3234
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
3335
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1690): Remove `pragma: NO COVER` once
@@ -314,7 +316,7 @@ def hash_sensitive_info(data: dict) -> dict:
314316
return hashed_data
315317

316318

317-
def _hash_value(value, field_name: str) -> str:
319+
def _hash_value(value, field_name: str) -> Optional[str]:
318320
"""Hashes a value and returns a formatted hash string."""
319321
if value is None:
320322
return None
@@ -343,7 +345,7 @@ def request_log(
343345
method: str,
344346
url: str,
345347
body: Optional[Any],
346-
headers: Optional[Dict[str, str]],
348+
headers: Optional[Mapping[str, str]],
347349
) -> None:
348350
"""
349351
Logs an HTTP request at the DEBUG level if logging is enabled.

google/auth/aio/transport/aiohttp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ async def __call__(
167167
timeout=client_timeout,
168168
**kwargs,
169169
)
170-
_helpers.response_log(_LOGGER, response)
170+
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1697): Add response log.
171171
return Response(response)
172172

173173
except aiohttp.ClientError as caught_exc:

google/auth/transport/_aiohttp_requests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
import asyncio
2424
import functools
25+
import logging
2526

2627
import aiohttp # type: ignore
27-
import logging
2828
import urllib3 # type: ignore
2929

30+
from google.auth import _helpers
3031
from google.auth import exceptions
3132
from google.auth import transport
32-
from google.auth import _helpers
3333
from google.auth.transport import requests
3434

3535

@@ -191,7 +191,7 @@ async def __call__(
191191
response = await self.session.request(
192192
method, url, data=body, headers=headers, timeout=timeout, **kwargs
193193
)
194-
_helpers.response_log(_LOGGER, response)
194+
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1697): Add response log.
195195
return _CombinedResponse(response)
196196

197197
except aiohttp.ClientError as caught_exc:

google/auth/transport/_http_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import socket
2020
import urllib
2121

22+
from google.auth import _helpers
2223
from google.auth import exceptions
2324
from google.auth import transport
24-
from google.auth import _helpers
2525

2626
_LOGGER = logging.getLogger(__name__)
2727

google/auth/transport/requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
create_urllib3_context,
3535
) # pylint: disable=ungrouped-imports
3636

37+
from google.auth import _helpers
3738
from google.auth import environment_vars
3839
from google.auth import exceptions
3940
from google.auth import transport
40-
from google.auth import _helpers
4141
import google.auth.transport._mtls_helper
4242
from google.oauth2 import service_account
4343

google/auth/transport/urllib3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242

4343
from packaging import version # type: ignore
4444

45+
from google.auth import _helpers
4546
from google.auth import environment_vars
4647
from google.auth import exceptions
4748
from google.auth import transport
48-
from google.auth import _helpers
4949
from google.oauth2 import service_account
5050

5151
if version.parse(urllib3.__version__) >= version.parse("2.0.0"): # pragma: NO COVER

tests/test__helpers.py

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

1515
import datetime
16-
import urllib
1716
import logging
1817
from unittest import mock
18+
import urllib
1919

2020
import pytest # type: ignore
2121

0 commit comments

Comments
 (0)