Skip to content

Commit 200abf6

Browse files
committed
Switch to httpx's new exception handling idiom
1 parent e5bc9a7 commit 200abf6

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

docs/client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ users can simply use the following pattern:
105105
.. code-block:: python
106106
107107
r = client.some_endpoint()
108-
assert r.status_code == 200, r.raise_for_status()
108+
assert r.status_code == httpx.codes.OK, r.raise_for_status()
109109
data = r.json()
110110
111111
The API indicates errors using the response status code, and this pattern will

docs/streaming.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ You can identify on which exchange a symbol is listed by using
430430
.. code-block:: python
431431
432432
r = c.search_instruments(['GOOG'], projection=c.Instrument.Projection.FUNDAMENTAL)
433-
assert r.status_code == 200, r.raise_for_status()
433+
assert r.status_code == httpx.codes.OK, r.raise_for_status()
434434
print(r.json()['GOOG']['exchange']) # Outputs NASDAQ
435435
436436
However, many symbols have order books available on these streams even though

docs/util.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ usage:
2828
# Assume client and order already exist and are valid
2929
account_id = 123456
3030
r = client.place_order(account_id, order)
31-
assert r.status_code == 200, raise_for_status()
31+
assert r.status_code == httpx.codes.OK, r.raise_for_status()
3232
order_id = Utils(client, account_id).extract_order_id(r)
3333
assert order_id is not None
3434

tda/streaming.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import asyncio
55
import copy
66
import datetime
7+
import httpx
78
import inspect
89
import json
910
import logging
@@ -344,7 +345,7 @@ async def login(self):
344345
r = self._client.get_user_principals(fields=[
345346
self._client.UserPrincipals.Fields.STREAMER_CONNECTION_INFO,
346347
self._client.UserPrincipals.Fields.STREAMER_SUBSCRIPTION_KEYS])
347-
assert r.status_code == 200, r.raise_for_status()
348+
assert r.status_code == httpx.codes.OK, r.raise_for_status()
348349
r = r.json()
349350

350351
await self._init_from_principals(r)

0 commit comments

Comments
 (0)