requests
requests copied to clipboard
Incorrect json() docstring
What json()
actually does - it deserializes JSON into a Python object.
So the docstring below must be wrong: https://github.com/psf/requests/blob/fab1fd10d0b115e635b9ef1364f8444089725000/requests/models.py#L894-L918
Do you mind if I take this task as an intro issue to the project? I'm looking to be a new contributor
This has tripped me up as well. I'm new to Python. I expected response.json() to return JSON, but it doesn't. I don't know if I'm expected to do something further to turn it into actual JSON (and if so, what), or if this is an oversight in the requests code.
I also ran into issues with this - besides the fact that it indeed returns a decoded Python representation of the content, I'm confused by the "if any" clause - there is nothing that checks the existence of content, nor if the response actually has Content-Type application/json set, it simply dumps self.text
into a json loader.
So a better way to phrase this might be along the lines of: "Tries to return a decoded representation of the response's content as if it were JSON"