From 7a281e74ecdd74f74efcd813165ec654b2e684f4 Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Thu, 16 Feb 2017 07:15:37 -0600 Subject: [PATCH 1/2] Correct docstring for Response.ok --- requests/models.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/requests/models.py b/requests/models.py index 76e9d039..8c1488ce 100644 --- a/requests/models.py +++ b/requests/models.py @@ -672,7 +672,13 @@ class Response(object): @property def ok(self): - """Returns true if :attr:`status_code` is 'OK'.""" + """Returns True if :attr:`status_code` is less than 400. + + This attribute checks if the status code of the response is between + 400 and 600 to see if there was a client error or a server error. If + the status code, is between 200 and 400, this will return True. This + is **not** a check to see if the response code is ``200 OK``. + """ try: self.raise_for_status() except HTTPError: From 8e049bd9eb49485dc98efd6f14ab7f76c084cf8b Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Thu, 16 Feb 2017 07:21:15 -0600 Subject: [PATCH 2/2] Update docstrings for Response.__{bool,nonzero}__ Like the docstring added to Response.ok these were misleading and vaguely incorrect. Better to be explicit than implicit. --- requests/models.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/requests/models.py b/requests/models.py index 8c1488ce..01b60afe 100644 --- a/requests/models.py +++ b/requests/models.py @@ -659,11 +659,23 @@ class Response(object): return '' % (self.status_code) def __bool__(self): - """Returns true if :attr:`status_code` is 'OK'.""" + """Returns True if :attr:`status_code` is less than 400. + + This attribute checks if the status code of the response is between + 400 and 600 to see if there was a client error or a server error. If + the status code, is between 200 and 400, this will return True. This + is **not** a check to see if the response code is ``200 OK``. + """ return self.ok def __nonzero__(self): - """Returns true if :attr:`status_code` is 'OK'.""" + """Returns True if :attr:`status_code` is less than 400. + + This attribute checks if the status code of the response is between + 400 and 600 to see if there was a client error or a server error. If + the status code, is between 200 and 400, this will return True. This + is **not** a check to see if the response code is ``200 OK``. + """ return self.ok def __iter__(self):