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

Ensure JSON representation is compact. #3363 #3367

Merged
merged 7 commits into from
Oct 28, 2024

Conversation

BERRADA-Omar
Copy link
Contributor

@BERRADA-Omar BERRADA-Omar commented Oct 26, 2024

Summary

this PR solves the issues mentionned here #3363

The following related issues could all be resolved together...

We should use ensure_ascii=False for more compact text representations.
We should use separators = (',', ':') for more compact list and object representations.
We should use allow_nan=False to disallow invalid Infinity and NaN representations.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

.gitignore Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
Copy link
Member

@tomchristie tomchristie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, thx. ☺️

@tomchristie tomchristie merged commit 9fd6f0c into encode:master Oct 28, 2024
5 checks passed
@@ -4,6 +4,7 @@
import pytest

import httpx
from httpx._content import encode_json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just noticed this accidentally snuck in a private import.

@BERRADA-Omar would you be up for refactoring these tests?

We can test this against public API using httpx.Request(). Eg...

data = {...}
req = httpx.Request("POST", "https://www.example.com/", json=data)
assert req.content == ...
assert req.headers = ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants