Skip to content

Commit 4d172bb

Browse files
authored
Merge pull request #13 from jparise/use_cache
Encode 'use_cache' as a JSON boolean value
2 parents 4747592 + 63c878d commit 4d172bb

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

instaparser/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def article(self, url: str, content: str | None = None, output: str = "html", us
212212
"output": output,
213213
}
214214
if not use_cache:
215-
payload["use_cache"] = "false"
215+
payload["use_cache"] = False
216216
if content is not None:
217217
payload["content"] = content
218218

@@ -274,7 +274,7 @@ def summary(
274274
"stream": stream_callback is not None,
275275
}
276276
if not use_cache:
277-
payload["use_cache"] = "false"
277+
payload["use_cache"] = False
278278
if content is not None:
279279
payload["content"] = content
280280

@@ -337,7 +337,7 @@ def pdf(
337337
raise InstaparserValidationError("output must be 'html', 'text', or 'markdown'")
338338

339339
if file is not None:
340-
fields = {"output": output}
340+
fields: dict[str, Any] = {"output": output}
341341
if not use_cache:
342342
fields["use_cache"] = "false"
343343
if url:
@@ -353,7 +353,7 @@ def pdf(
353353
except HTTPError as e:
354354
_map_http_error(e)
355355
elif url:
356-
params = {
356+
params: dict[str, Any] = {
357357
"url": url,
358358
"output": output,
359359
}

tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_with_content(self, client, mock_request):
170170
def test_use_cache_false(self, client, mock_request):
171171
mock_request.return_value = make_response(json_data=ARTICLE_DATA)
172172
client.article(url="u", use_cache=False)
173-
assert mock_request.call_args[1]["json_data"]["use_cache"] == "false"
173+
assert mock_request.call_args[1]["json_data"]["use_cache"] is False
174174

175175
def test_invalid_output(self, client):
176176
with pytest.raises(InstaparserValidationError, match="output must be"):
@@ -200,7 +200,7 @@ def test_with_content(self, client, mock_request):
200200
def test_use_cache_false(self, client, mock_request):
201201
mock_request.return_value = make_response(json_data=SUMMARY_DATA)
202202
client.summary(url="u", use_cache=False)
203-
assert mock_request.call_args[1]["json_data"]["use_cache"] == "false"
203+
assert mock_request.call_args[1]["json_data"]["use_cache"] is False
204204

205205
def test_empty_response(self, client, mock_request):
206206
mock_request.return_value = make_response(json_data={})

0 commit comments

Comments
 (0)