Skip to content

Commit d6f4818

Browse files
authored
Merge pull request #3877 from sigmavirus24/update-docstring
Correct docstring for Response.ok
2 parents e674aa1 + 8e049bd commit d6f4818

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

requests/models.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,11 +659,23 @@ def __repr__(self):
659659
return '<Response [%s]>' % (self.status_code)
660660

661661
def __bool__(self):
662-
"""Returns true if :attr:`status_code` is 'OK'."""
662+
"""Returns True if :attr:`status_code` is less than 400.
663+
664+
This attribute checks if the status code of the response is between
665+
400 and 600 to see if there was a client error or a server error. If
666+
the status code, is between 200 and 400, this will return True. This
667+
is **not** a check to see if the response code is ``200 OK``.
668+
"""
663669
return self.ok
664670

665671
def __nonzero__(self):
666-
"""Returns true if :attr:`status_code` is 'OK'."""
672+
"""Returns True if :attr:`status_code` is less than 400.
673+
674+
This attribute checks if the status code of the response is between
675+
400 and 600 to see if there was a client error or a server error. If
676+
the status code, is between 200 and 400, this will return True. This
677+
is **not** a check to see if the response code is ``200 OK``.
678+
"""
667679
return self.ok
668680

669681
def __iter__(self):
@@ -672,7 +684,13 @@ def __iter__(self):
672684

673685
@property
674686
def ok(self):
675-
"""Returns true if :attr:`status_code` is 'OK'."""
687+
"""Returns True if :attr:`status_code` is less than 400.
688+
689+
This attribute checks if the status code of the response is between
690+
400 and 600 to see if there was a client error or a server error. If
691+
the status code, is between 200 and 400, this will return True. This
692+
is **not** a check to see if the response code is ``200 OK``.
693+
"""
676694
try:
677695
self.raise_for_status()
678696
except HTTPError:

0 commit comments

Comments
 (0)