Skip to content

Why requests return a separate status? #58

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

Open
Toreno96 opened this issue Oct 12, 2023 · 0 comments
Open

Why requests return a separate status? #58

Toreno96 opened this issue Oct 12, 2023 · 0 comments

Comments

@Toreno96
Copy link

According to your official docs, requests return a tuple of (response, status). This is counter-intuitive for me because HTTP status is already present as a property of response, even if the response is other than 2xx:

In [25]: resp, status = jobs_api.getJobDetails('foo')
Non 200 response:404   RequestId:Unknown   URL:https://api.smartling.com/jobs-api/v3/projects/3bea86d16/jobs/foo   response:b'{"response":{"code":"NOT_FOUND_ERROR","errors":[{"key":"not.found","message":"Translation job is not found","details":null}]}}'

In [26]: resp.statusCode
Out[26]: 404

In [27]: resp.statusCode == status
Out[27]: True

That makes it slightly less convenient to use because for each request I would need to remember to ignore status via resp, _ = ….

Or is there a reason status is separate and I should prefer it over resp.statusCode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant