Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for installing simplejson as an optional extra by updating the extras_require section in setup.py.
Rationale
As discussed in issue #7032, requests currently supports simplejson if it is already present in the environment, but there is no explicit or reliable way to install it alongside requests. This can lead to unexpected behavior if simplejson is removed or missing.
By defining an optional extra, users can install it explicitly using:
pip install requests[simplejson]
or with Poetry:
poetry add requests[simplejson]
This follows Python packaging best practices and makes the dependency relationship clear without modifying core behavior of the library.
Changes
Updated setup.py by adding the following entry inside extras_require:
'simplejson': ['simplejson']
Verification
Tested locally in a clean environment.
pip install .[simplejson]
Verified import with:
import simplejson
print("simplejson imported successfully!")
Output:
simplejson imported successfully!
Closes #7032