psf / psf/requests

Docstring examples in `from_key_val_list` show the pre-3.12 OrderedDict repr

Open Beginner friendly
#7,627 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.