Skip to content

Commit 490017a

Browse files
authored
Fix failing imports from httpcore (#5891)
Refactor `test_rigetti_qcs_service_api_call()` to use public API from httpx instead of private API from httpcore which changed. Also require pyquil>=3.2.0 to ensure httpx and httpcore include API change at httpcore==0.14.0, encode/httpcore@f9b9391. Note: pyquil creates indirect dependency on httpcore as follows: - pyquil (==3.2.0) requires qcs-api-client (>=0.20.13,<0.22.0) - qcs-api-client (==0.21.2) requires httpx (>=0.23.0,<0.24.0) - httpx (==0.23.0) requires httpcore (>=0.15.0,<0.16.0)
1 parent cd97be1 commit 490017a

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

cirq-rigetti/cirq_rigetti/service_test.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# pylint: disable=wrong-or-nonexistent-copyright-notice
2-
from typing import Iterator
2+
from typing import Optional, Iterator
33
import pytest
44
import httpx
5-
import httpcore
6-
from httpcore._types import URL, Headers
75
from cirq_rigetti import get_rigetti_qcs_service, RigettiQCSService
86

97

@@ -20,20 +18,13 @@ def test_rigetti_qcs_service_api_call():
2018
"""test that `RigettiQCSService` will use a custom defined client when the
2119
user specifies one to make an API call."""
2220

23-
class Response(httpcore.SyncByteStream):
24-
def __iter__(self) -> Iterator[bytes]:
21+
class Response(httpx.Response):
22+
def iter_bytes(self, chunk_size: Optional[int] = None) -> Iterator[bytes]:
2523
yield b"{\"quantumProcessors\": [{\"id\": \"Aspen-8\"}]}" # pragma: nocover
2624

27-
class Transport(httpcore.SyncHTTPTransport):
28-
def request(
29-
self,
30-
method: bytes,
31-
url: URL,
32-
headers: Headers = None,
33-
stream: httpcore.SyncByteStream = None,
34-
ext: dict = None,
35-
):
36-
return 200, [('Content-Type', 'application/json')], Response(), {}
25+
class Transport(httpx.BaseTransport):
26+
def handle_request(self, request: httpx.Request) -> httpx.Response:
27+
return Response(200)
3728

3829
client = httpx.Client(base_url="https://mock.api.qcs.rigetti.com", transport=Transport())
3930

cirq-rigetti/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pyquil>=3.0.0
1+
pyquil>=3.2.0

0 commit comments

Comments
 (0)