diff --git a/.circleci/config.yml b/.circleci/config.yml index 3d174a8..b5f2620 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ executors: - image: cimg/python:3.12 python-vm: machine: - - image: ubuntu-2204:current + image: ubuntu-2204:current workflows: ci: @@ -59,7 +59,7 @@ jobs: name: Setup ArangoDB command: | chmod +x starter.sh - ./starter.sh ${{ matrix.arangodb_config }} ${{ matrix.arangodb_license }} ${{ matrix.arangodb_version }} + ./starter.sh << parameters.arangodb_config >> << parameters.arangodb_license >> << parameters.arangodb_version >> - restore_cache: key: pip-and-local-cache - run: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ae48c5f..4814fbe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 - # See https://pre-commit.com/hooks.html + # See https://pre-commit.com/hooks.html hooks: - id: check-case-conflict - id: check-executables-have-shebangs diff --git a/arangoasync/http.py b/arangoasync/http.py index 35db1ad..b6ebfc0 100644 --- a/arangoasync/http.py +++ b/arangoasync/http.py @@ -156,7 +156,7 @@ async def send_request( url=str(response.real_url), headers=response.headers, status_code=response.status, - status_text=response.reason, + status_text=str(response.reason), raw_body=raw_body, ) diff --git a/arangoasync/request.py b/arangoasync/request.py index bd68e4a..5971f92 100644 --- a/arangoasync/request.py +++ b/arangoasync/request.py @@ -6,7 +6,7 @@ from enum import Enum, auto from typing import Optional -from arangoasync.typings import Headers, Params +from arangoasync.typings import Params, RequestHeaders from arangoasync.version import __version__ @@ -52,18 +52,18 @@ def __init__( self, method: Method, endpoint: str, - headers: Optional[Headers] = None, + headers: Optional[RequestHeaders] = None, params: Optional[Params] = None, data: Optional[str] = None, ) -> None: self.method: Method = method self.endpoint: str = endpoint - self.headers: Headers = self._normalize_headers(headers) + self.headers: RequestHeaders = self._normalize_headers(headers) self.params: Params = self._normalize_params(params) self.data: Optional[str] = data @staticmethod - def _normalize_headers(headers: Optional[Headers]) -> Headers: + def _normalize_headers(headers: Optional[RequestHeaders]) -> RequestHeaders: """Normalize request headers. Parameters: @@ -73,7 +73,7 @@ def _normalize_headers(headers: Optional[Headers]) -> Headers: dict: Normalized request headers. """ driver_header = f"arangoasync/{__version__}" - normalized_headers: Headers = { + normalized_headers: RequestHeaders = { "charset": "utf-8", "content-type": "application/json", "x-arango-driver": driver_header, diff --git a/arangoasync/response.py b/arangoasync/response.py index a60d753..63b10fb 100644 --- a/arangoasync/response.py +++ b/arangoasync/response.py @@ -5,7 +5,7 @@ from typing import Optional from arangoasync.request import Method -from arangoasync.typings import Headers +from arangoasync.typings import ResponseHeaders class Response: @@ -14,7 +14,7 @@ class Response: Parameters: method (Method): HTTP method. url (str): API URL. - headers (dict | None): Response headers. + headers (dict): Response headers. status_code (int): Response status code. status_text (str): Response status text. raw_body (bytes): Raw response body. @@ -22,7 +22,7 @@ class Response: Attributes: method (Method): HTTP method. url (str): API URL. - headers (dict | None): Response headers. + headers (dict): Response headers. status_code (int): Response status code. status_text (str): Response status text. raw_body (bytes): Raw response body. @@ -47,14 +47,14 @@ def __init__( self, method: Method, url: str, - headers: Headers, + headers: ResponseHeaders, status_code: int, status_text: str, raw_body: bytes, ) -> None: self.method: Method = method self.url: str = url - self.headers: Headers = headers + self.headers: ResponseHeaders = headers self.status_code: int = status_code self.status_text: str = status_text self.raw_body: bytes = raw_body diff --git a/arangoasync/typings.py b/arangoasync/typings.py index a96bbac..b3622f9 100644 --- a/arangoasync/typings.py +++ b/arangoasync/typings.py @@ -1,14 +1,18 @@ __all__ = [ - "Headers", + "RequestHeaders", + "ResponseHeaders", "Params", ] from typing import MutableMapping -from multidict import MultiDict +from multidict import CIMultiDictProxy, MultiDict -Headers = MutableMapping[str, str] | MultiDict[str] -Headers.__doc__ = """Type definition for HTTP headers""" +RequestHeaders = MutableMapping[str, str] | MultiDict[str] +RequestHeaders.__doc__ = """Type definition for request HTTP headers""" + +ResponseHeaders = MutableMapping[str, str] | MultiDict[str] | CIMultiDictProxy[str] +ResponseHeaders.__doc__ = """Type definition for response HTTP headers""" Params = MutableMapping[str, bool | int | str] Params.__doc__ = """Type definition for URL (query) parameters""" diff --git a/tests/test_http.py b/tests/test_http.py index a214bd1..a1047dc 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -12,7 +12,6 @@ async def test_AioHTTPClient_simple_request(url): request = Request( method=Method.GET, endpoint="/_api/version", - deserialize=False, ) response = await client.send_request(session, request) assert response.method == Method.GET @@ -28,7 +27,6 @@ async def test_AioHTTPClient_auth_pass(url, root, password): request = Request( method=Method.GET, endpoint="/_api/version", - deserialize=False, ) response = await client.send_request(session, request) assert response.method == Method.GET