Skip to content

Commit

Permalink
feat(auth): support auto-decompress argument passthrough (#713)
Browse files Browse the repository at this point in the history
Co-authored-by: fbalboaDialpad <fernando.balboa@dialpad.com>
  • Loading branch information
TheKevJames and fbalboaDialpad committed Apr 4, 2024
1 parent 57f5b7a commit e89a751
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
14 changes: 14 additions & 0 deletions auth/gcloud/aio/auth/session.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import importlib.metadata
import logging
import threading
import warnings
from abc import ABCMeta
from abc import abstractmethod
from abc import abstractproperty
Expand Down Expand Up @@ -54,6 +55,7 @@ async def get(
self, url: str, headers: Optional[Mapping[str, str]],
timeout: float, params: Optional[Mapping[str, Union[int, str]]],
stream: bool,
auto_decompress: bool,
) -> Response:
pass

Expand Down Expand Up @@ -198,6 +200,7 @@ async def get( # type: ignore[override]
timeout: Timeout = 10,
params: Optional[Mapping[str, Union[int, str]]] = None,
stream: Optional[bool] = None,
auto_decompress: bool = True,
) -> aiohttp.ClientResponse:
if not isinstance(timeout, aiohttp.ClientTimeout):
timeout = aiohttp.ClientTimeout(total=timeout)
Expand All @@ -211,6 +214,7 @@ async def get( # type: ignore[override]
resp = await self.session.get(
url, headers=headers,
timeout=timeout, params=params,
auto_decompress=auto_decompress,
)
await _raise_for_status(resp)
return resp
Expand Down Expand Up @@ -335,7 +339,17 @@ async def get(
timeout: float = 10,
params: Optional[Mapping[str, Union[int, str]]] = None,
stream: bool = False,
auto_decompress: bool = True,
) -> Response:
if not auto_decompress and not stream:
warnings.warn(
'the requests library always decompresses responses when '
'outside of streaming mode; when audo_decompress is '
'False, stream = True must also be set',
UserWarning,
)
stream = True

with self.google_api_lock:
resp = self.session.get(
url, headers=headers, timeout=timeout,
Expand Down
20 changes: 10 additions & 10 deletions auth/poetry.rest.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand.
# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand.

[[package]]
name = "backoff"
Expand Down Expand Up @@ -325,13 +325,13 @@ testing = ["pytest", "pytest-benchmark"]

[[package]]
name = "pycparser"
version = "2.21"
version = "2.22"
description = "C parser in Python"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
python-versions = ">=3.8"
files = [
{file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"},
{file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"},
{file = "pycparser-2.22-py3-none-any.whl", hash = "sha256:c3702b6d3dd8c7abc1afa565d7e63d53a1d0bd86cdc24edd75470f4de499cfcc"},
{file = "pycparser-2.22.tar.gz", hash = "sha256:491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6"},
]

[[package]]
Expand Down Expand Up @@ -375,17 +375,17 @@ testing = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygm

[[package]]
name = "pytest-mock"
version = "3.12.0"
version = "3.14.0"
description = "Thin-wrapper around the mock package for easier use with pytest"
optional = false
python-versions = ">=3.8"
files = [
{file = "pytest-mock-3.12.0.tar.gz", hash = "sha256:31a40f038c22cad32287bb43932054451ff5583ff094bca6f675df2f8bc1a6e9"},
{file = "pytest_mock-3.12.0-py3-none-any.whl", hash = "sha256:0972719a7263072da3a21c7f4773069bcc7486027d7e8e1f81d98a47e701bc4f"},
{file = "pytest-mock-3.14.0.tar.gz", hash = "sha256:2719255a1efeceadbc056d6bf3df3d1c5015530fb40cf347c0f9afac88410bd0"},
{file = "pytest_mock-3.14.0-py3-none-any.whl", hash = "sha256:0b72c38033392a5f4621342fe11e9219ac11ec9d375f8e2a0c164539e0d70f6f"},
]

[package.dependencies]
pytest = ">=5.0"
pytest = ">=6.2.5"

[package.extras]
dev = ["pre-commit", "pytest-asyncio", "tox"]
Expand Down Expand Up @@ -442,4 +442,4 @@ zstd = ["zstandard (>=0.18.0)"]
[metadata]
lock-version = "2.0"
python-versions = ">= 3.8, < 4.0"
content-hash = "ff6f080b1cdcf07dd2285eb123053d94676b1e95edababecee8ea1447b981958"
content-hash = "1fe9a474cdf13c08c86dfd7155039849028f39a456783a75b8f5eb6b6fa8270e"
6 changes: 3 additions & 3 deletions auth/pyproject.rest.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "gcloud-rest-auth"
version = "5.2.2"
version = "5.3.0"
description = "Python Client for Google Cloud Auth"
readme = "README.rst"

Expand Down Expand Up @@ -31,8 +31,8 @@ requests = ">= 2.2.1, < 3.0.0"

[tool.poetry.group.dev.dependencies]
pytest = "8.1.1"
# pytest-asyncio = "0.23.5"
pytest-mock = "3.12.0"
# pytest-asyncio = "0.23.6"
pytest-mock = "3.14.0"

[[tool.poetry.source]]
name = "pypi"
Expand Down
2 changes: 1 addition & 1 deletion auth/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "gcloud-aio-auth"
version = "5.2.2"
version = "5.3.0"
description = "Python Client for Google Cloud Auth"
readme = "README.rst"

Expand Down

0 comments on commit e89a751

Please sign in to comment.