Docstring examples in `from_key_val_list` show the pre-3.12 OrderedDict repr
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 54.3k
- Forks
- 10.4k
- Avg merge
- 16h 43m
- Merged PRs (30d)
- 3
Description
src/requests/utils.py's from_key_val_list docstring shows:
>>> from_key_val_list([('key', 'val')])
OrderedDict([('key', 'val')])
Since Python 3.12, collections.OrderedDict.__repr__ uses the regular dict form (cpython gh-101446), so on any currently supported Python this actually prints:
OrderedDict({'key': 'val'})
Reproducer (Python 3.13.5, requests 2.34.2):
>>> from requests.utils import from_key_val_list
>>> from_key_val_list([('key', 'val')])
OrderedDict({'key': 'val'})
>>> from_key_val_list({'key': 'val'})
OrderedDict({'key': 'val'})
The ValueError example in the same docstring is still accurate. Both stale occurrences are on lines 351 and 357, and a grep of the rest of the package found no others.
I have a two-line fix ready on a fork and would be glad to open a pull request if that's welcome. (The compare page says PRs are limited to collaborators, hence this issue.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open src/requests/utils.py and inspect the from_key_val_list docstring around lines 351 and 357. Run the two examples shown in the issue to confirm the current OrderedDict representation, then update both stale occurrences so the documentation matches Python 3.12 and later.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 92/100