Skip to content

Commit 31823d7

Browse files
abhibavishiclaude
andcommitted
fix: header property footgun, dead conftest, async test gaps, __version__
- Replace _headers @Property with _make_headers() method to avoid false dynamic impression - Update client.py and async_client.py to call _make_headers() at construction - Delete dead tests/conftest.py (fixtures shadowed in every test file, helpers unused) - Strengthen async domain_overlap test to assert comma-joined value, not just key presence - Add missing async link_intersect two-params test to match sync coverage - Add __version__ = "0.1.0" to rankparse/__init__.py and __all__ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8c441fb commit 31823d7

6 files changed

Lines changed: 19 additions & 29 deletions

File tree

rankparse/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
__version__ = "0.1.0"
2+
13
from .client import RankParseClient
24
from .async_client import AsyncRankParseClient
35
from .errors import (
@@ -10,6 +12,7 @@
1012
)
1113

1214
__all__ = [
15+
"__version__",
1316
"RankParseClient",
1417
"AsyncRankParseClient",
1518
"RankParseError",

rankparse/_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ def _raise_for_status(self, response: httpx.Response) -> None:
4646
else:
4747
raise APIError(message, code, status)
4848

49-
@property
50-
def _headers(self) -> dict:
49+
def _make_headers(self) -> dict:
5150
return {
5251
"X-API-Key": self._api_key,
5352
"Accept": "application/json",

rankparse/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class AsyncRankParseClient(BaseClient):
77
def __init__(self, api_key: str, base_url: str = DEFAULT_BASE_URL, timeout: float = 30.0) -> None:
88
super().__init__(api_key, base_url, timeout)
9-
self._http = httpx.AsyncClient(base_url=self._base_url, headers=self._headers, timeout=self._timeout)
9+
self._http = httpx.AsyncClient(base_url=self._base_url, headers=self._make_headers(), timeout=self._timeout)
1010

1111
async def aclose(self) -> None:
1212
await self._http.aclose()

rankparse/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class RankParseClient(BaseClient):
77
def __init__(self, api_key: str, base_url: str = DEFAULT_BASE_URL, timeout: float = 30.0) -> None:
88
super().__init__(api_key, base_url, timeout)
9-
self._http = httpx.Client(base_url=self._base_url, headers=self._headers, timeout=self._timeout)
9+
self._http = httpx.Client(base_url=self._base_url, headers=self._make_headers(), timeout=self._timeout)
1010

1111
def close(self) -> None:
1212
self._http.close()

tests/conftest.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

tests/test_async_client.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,19 @@ async def test_domain_overlap_comma_joined(self, async_client):
8686
)
8787
)
8888
await async_client.domain_overlap(["a.com", "b.com"])
89-
assert "domains=" in str(route.calls[0].request.url)
89+
url_str = str(route.calls[0].request.url)
90+
assert "domains=a.com%2Cb.com" in url_str or "domains=a.com,b.com" in url_str
91+
92+
@pytest.mark.asyncio
93+
@respx.mock
94+
async def test_link_intersect_two_params(self, async_client):
95+
route = respx.get(f"{BASE_URL}/link-intersect").mock(
96+
return_value=httpx.Response(200, json={"data": [], "credits_used": 5, "credits_remaining": 995})
97+
)
98+
await async_client.link_intersect("x.com", "y.com")
99+
url_str = str(route.calls[0].request.url)
100+
assert "domain_a=x.com" in url_str
101+
assert "domain_b=y.com" in url_str
90102

91103
@pytest.mark.asyncio
92104
@respx.mock

0 commit comments

Comments
 (0)