requests
requests copied to clipboard
return response from `raise_for_status`
I'd guess this has been requested before, but couldn't find any pointers so far. (I also understand that requests does not accept feature requests, but this is code-wise a trivial one-line change, so I'm going to try anyway :smile: ).
Feature request: return self from Response.raise_for_status() (instead of returning None implicitly).
That allows using it in a compact chained/fluent manner, for example
data = [
requests.get(url).raise_for_status().json()
for url in urls
]
With the current raise_for_status you can not use list comprehension like in this examle because you have to use separate statements for the .get(), .raise_for_status() and .json() .
(An alternative solution could be to add some kind of raise_for_status opt-in option to .get() and alike, but that would require a lot more code changes than a simple return self as proposed higher)
This project is in indefinite feature-freeze and not changing the API in ways that may be surprising for existing users. Also I'm certain this has been requested before but am on mobile and can't easily search
I am junior SDE, and I want to contribute to open source. This is my first time. Can I work on this ?
This project is in indefinite feature-freeze
@sigmavirus24 Is this still true?? Why is it in a feature-freeze?
Why is it in a feature-freeze?
It's documented here: https://requests.readthedocs.io/en/latest/dev/contributing/#feature-requests