Skip to content

Commit

Permalink
Rename ok to is_success on InternalHttpResponse
Browse files Browse the repository at this point in the history
Taking some inspiration from httpx here, which I think had good reasoning for this change from requests.
  • Loading branch information
Mr0grog committed Dec 16, 2023
1 parent eeadae1 commit 6f85af8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions wayback/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def redirect_url(self) -> str:
return self._redirect_url

@property
def ok(self) -> bool:
def is_success(self) -> bool:
return self.status_code >= 200 and self.status_code < 300

# XXX: This and _release_conn probably need wrapping with RLock!
Expand Down Expand Up @@ -1496,7 +1496,7 @@ def get_memento(self, url, timestamp=None, mode=Mode.original, *,
raise BlockedByRobotsError(f'{url} is blocked by robots.txt')
elif message:
raise MementoPlaybackError(f'Memento at {url} could not be played: {message}')
elif response.ok:
elif response.is_success:
# TODO: Raise more specific errors for the possible
# cases here. We *should* only arrive here when
# there's a redirect and:
Expand Down
2 changes: 1 addition & 1 deletion wayback/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ def test_request_retries(self, urllib3_mock):
{'text': 'good', 'status_code': 200}])
session = WaybackSession(retries=2, backoff=0.1)
response = session.request('GET', 'http://test.com')
assert response.ok
assert response.is_success

session.close()

Expand Down

0 comments on commit 6f85af8

Please sign in to comment.