Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return response from raise_for_status #6215

Closed
soxofaan opened this issue Aug 18, 2022 · 4 comments
Closed

return response from raise_for_status #6215

soxofaan opened this issue Aug 18, 2022 · 4 comments

Comments

@soxofaan
Copy link

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 😄 ).

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)

@sigmavirus24
Copy link
Contributor

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

@ThugNinja4708
Copy link

I am junior SDE, and I want to contribute to open source. This is my first time.
Can I work on this ?

@sigmavirus24 sigmavirus24 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 28, 2023
@sohang3112
Copy link

This project is in indefinite feature-freeze

@sigmavirus24 Is this still true?? Why is it in a feature-freeze?

@Mariatta
Copy link

Why is it in a feature-freeze?

It's documented here: https://requests.readthedocs.io/en/latest/dev/contributing/#feature-requests

@psf psf locked as resolved and limited conversation to collaborators Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants