Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use explicit timeout type instead of using httpx._Timeout #11

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ dependencies = [


[tool.setuptools.package-data]
waylay = ["py.typed"]

[tool.setuptools.packages.find]
where = ["src/"]
include = ["waylay*"]
exclude = []
namespaces = true

[project.optional-dependencies]
dev = [
Expand All @@ -50,6 +53,7 @@ services = [
services-types = [
"waylay_registry_types @ git+https://github.com/waylayio/waylay-py-services@main#subdirectory=services/registry/waylay_registry_types"
]

[tool.pytest.ini_options]
asyncio_mode = "auto"
env = [
Expand Down
3 changes: 2 additions & 1 deletion requirements/requirements.3.11.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
anyio==4.2.0
appdirs==1.4.4
certifi>=2023.11.17
certifi>=2024.2.2
ecdsa==0.18.0
h11==0.14.0
httpcore==1.0.2
Expand All @@ -13,4 +13,5 @@ python-magic==0.4.27
rsa==4.9
six==1.16.0
sniffio==1.3.0
typeguard==4.1.5
typing_extensions==4.9.0
29 changes: 15 additions & 14 deletions requirements/requirements.all.3.11.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
annotated-types==0.6.0
anyio==4.2.0
appdirs==1.4.4
astroid==3.0.2
astroid==3.0.3
autopep8==2.0.4
certifi==2023.11.17
certifi==2024.2.2
charset-normalizer==3.3.2
coverage==7.4.0
dill==0.3.7
coverage==7.4.1
dill==0.3.8
docformatter==1.7.5
ecdsa==0.18.0
h11==0.14.0
Expand All @@ -19,33 +19,34 @@ mccabe==0.7.0
mypy==1.8.0
mypy-extensions==1.0.0
packaging==23.2
platformdirs==4.1.0
pluggy==1.3.0
platformdirs==4.2.0
pluggy==1.4.0
pyasn1==0.5.1
pycodestyle==2.11.1
pydantic==2.5.3
pydantic_core==2.14.6
pydantic==2.6.1
pydantic_core==2.16.2
pydocstyle==6.3.0
pylint==3.0.3
pytest==7.4.4
pytest-asyncio==0.23.3
pytest-asyncio==0.23.4
pytest-cov==4.1.0
pytest-httpx==0.28.0
pytest-mock==3.12.0
pytest_httpx==0.29.0
python-dateutil==2.8.2
python-jose==3.3.0
python-magic==0.4.27
rsa==4.9
six==1.16.0
sniffio==1.3.0
snowballstemmer==2.2.0
syrupy==4.6.0
syrupy==4.6.1
tomlkit==0.12.3
typeguard==4.1.5
types-appdirs==1.4.3.5
types-pyasn1==0.5.0.20240106
types-pyasn1==0.5.0.20240205
types-python-dateutil==2.8.19.20240106
types-python-jose==3.3.4.20240106
typing_extensions==4.9.0
untokenize==0.1.1
waylay_registry_api @ git+https://github.com/waylayio/waylay-py-services@21b3e048e9ff9bcb1718b48fbf500627c9a7a01e#subdirectory=services/registry/waylay_registry_api
waylay_registry_types @ git+https://github.com/waylayio/waylay-py-services@21b3e048e9ff9bcb1718b48fbf500627c9a7a01e#subdirectory=services/registry/waylay_registry_types
waylay_registry_api @ git+https://github.com/waylayio/waylay-py-services@13f211925f826cee8537220e705c0eb98b62b7cd#subdirectory=services/registry/waylay_registry_api
waylay_registry_types @ git+https://github.com/waylayio/waylay-py-services@13f211925f826cee8537220e705c0eb98b62b7cd#subdirectory=services/registry/waylay_registry_types
26 changes: 13 additions & 13 deletions requirements/requirements.dev.3.11.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
annotated-types==0.6.0
astroid==3.0.2
astroid==3.0.3
autopep8==2.0.4
charset-normalizer==3.3.2
coverage==7.4.0
dill==0.3.7
coverage==7.4.1
dill==0.3.8
docformatter==1.7.5
iniconfig==2.0.0
isort==5.13.2
mccabe==0.7.0
mypy-extensions==1.0.0
mypy==1.8.0
packaging==23.2
platformdirs==4.1.0
pluggy==1.3.0
platformdirs==4.2.0
pluggy==1.4.0
pycodestyle==2.11.1
pydantic==2.5.3
pydantic_core==2.14.6
pydantic==2.6.1
pydantic_core==2.16.2
pydocstyle==6.3.0
pylint==3.0.3
pytest-asyncio==0.23.3
pytest-asyncio==0.23.4
pytest-cov==4.1.0
pytest-httpx==0.28.0
pytest-mock==3.12.0
pytest==7.4.4
pytest_httpx==0.29.0
snowballstemmer==2.2.0
syrupy==4.6.0
syrupy==4.6.1
tomlkit==0.12.3
types-appdirs==1.4.3.5
types-pyasn1==0.5.0.20240106
types-pyasn1==0.5.0.20240205
types-python-dateutil==2.8.19.20240106
types-python-jose==3.3.4.20240106
untokenize==0.1.1
waylay_registry_api @ git+https://github.com/waylayio/waylay-py-services@21b3e048e9ff9bcb1718b48fbf500627c9a7a01e#subdirectory=services/registry/waylay_registry_api
waylay_registry_types @ git+https://github.com/waylayio/waylay-py-services@21b3e048e9ff9bcb1718b48fbf500627c9a7a01e#subdirectory=services/registry/waylay_registry_types
waylay_registry_api @ git+https://github.com/waylayio/waylay-py-services@13f211925f826cee8537220e705c0eb98b62b7cd#subdirectory=services/registry/waylay_registry_api
waylay_registry_types @ git+https://github.com/waylayio/waylay-py-services@13f211925f826cee8537220e705c0eb98b62b7cd#subdirectory=services/registry/waylay_registry_types
1 change: 1 addition & 0 deletions src/waylay/api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def param_serialize(
header_params = dict(header_params or {})
header_params.update(self.default_headers)
if header_params:
header_params = {k.lower(): v for k, v in header_params.items()}
header_params = self.__sanitize_for_serialization(header_params)

# path parameters
Expand Down
9 changes: 6 additions & 3 deletions src/waylay/api/rest.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
"""REST client implementation."""

from io import BufferedReader
from typing import Any, Mapping, Optional
from typing import Any, Mapping, Optional, Tuple, Union
from typeguard import check_type
import httpx
from waylay.api.api_config import ApiConfig

from waylay.api.api_exceptions import ApiValueError

RESTResponse = httpx.Response
RESTTimeout = httpx._types.TimeoutTypes
RESTTimeout = Union[
Optional[float],
Tuple[Optional[float], Optional[float], Optional[float], Optional[float]],
]


class RESTClient:
Expand Down Expand Up @@ -75,7 +78,7 @@ async def request(

# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
content_type = headers.get('Content-Type')
content_type = headers.get('content-type')
if files or content_type and content_type == 'multipart/form-data':
kwargs.update({'files': files})
elif isinstance(body, (bytes, bytearray, BufferedReader)):
Expand Down
18 changes: 9 additions & 9 deletions test/unit/api/__snapshots__/api_client_test.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@
'body': None,
'files': None,
'header_params': dict({
'User-Agent': 'waylay-sdk/python/0.0.0',
'user-agent': 'waylay-sdk/python/0.0.0',
'x-my-header': 'header_value',
}),
'method': 'GET',
Expand Down Expand Up @@ -486,7 +486,7 @@
}),
'files': None,
'header_params': dict({
'User-Agent': 'waylay-sdk/python/0.0.0',
'user-agent': 'waylay-sdk/python/0.0.0',
'x-my-header': 'header_value',
}),
'method': 'PATCH',
Expand Down Expand Up @@ -515,7 +515,7 @@
'file2': '<... other binary content ...>',
}),
'header_params': dict({
'User-Agent': 'waylay-sdk/python/0.0.0',
'user-agent': 'waylay-sdk/python/0.0.0',
}),
'method': 'POST',
'query_params': dict({
Expand Down Expand Up @@ -549,7 +549,7 @@
}),
'files': None,
'header_params': dict({
'User-Agent': 'waylay-sdk/python/0.0.0',
'user-agent': 'waylay-sdk/python/0.0.0',
}),
'method': 'PUT',
'query_params': None,
Expand Down Expand Up @@ -581,7 +581,7 @@
}),
'files': None,
'header_params': dict({
'User-Agent': 'waylay-sdk/python/0.0.0',
'user-agent': 'waylay-sdk/python/0.0.0',
}),
'method': 'PUT',
'query_params': None,
Expand All @@ -606,7 +606,7 @@
'body': '{"name":"Lord Biscuit, Master of Naps","owner":{"id":123,"name":"Simon"},"tag":"doggo"}',
'files': None,
'header_params': dict({
'User-Agent': 'waylay-sdk/python/0.0.0',
'user-agent': 'waylay-sdk/python/0.0.0',
}),
'method': 'PUT',
'query_params': None,
Expand All @@ -631,7 +631,7 @@
'body': b'..some binary content..',
'files': None,
'header_params': dict({
'User-Agent': 'waylay-sdk/python/0.0.0',
'user-agent': 'waylay-sdk/python/0.0.0',
}),
'method': 'POST',
'query_params': None,
Expand All @@ -658,8 +658,8 @@
}),
'files': None,
'header_params': dict({
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'waylay-sdk/python/0.0.0',
'content-type': 'application/x-www-form-urlencoded',
'user-agent': 'waylay-sdk/python/0.0.0',
}),
'method': 'POST',
'query_params': None,
Expand Down