Skip to content

Commit 566eec1

Browse files
fixed extra_headers and ws.open (#145)
* fixed extra_headers and ws.open * Bump minimum Python requirement to 3.9 for Websockets>=14 and update websocket requirement in pyproject.toml * Update pytr/api.py * ruff format --------- Co-authored-by: Niklas Rosenstein <[email protected]>
1 parent b6e45d5 commit 566eec1

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "pytr"
77
version = "0.3.1"
88
description = "Use TradeRepublic in terminal"
99
readme = "README.md"
10-
requires-python = ">=3.8"
10+
requires-python = ">=3.9"
1111
license = { text = "MIT" }
1212
authors = [
1313
{ name = "marzzzello", email = "[email protected]" }
@@ -30,7 +30,7 @@ dependencies = [
3030
"pygments",
3131
"requests_futures",
3232
"shtab",
33-
"websockets>=10.1,<14",
33+
"websockets>=14",
3434
"babel",
3535
]
3636

pytr/api.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def _web_request(self, url_path, payload=None, method="GET"):
263263
return self._websession.request(method=method, url=f"{self._host}{url_path}", data=payload)
264264

265265
async def _get_ws(self):
266-
if self._ws and self._ws.open:
266+
if self._ws and self._ws.close_code is None:
267267
return self._ws
268268

269269
self.log.info("Connecting to websocket ...")
@@ -289,7 +289,9 @@ async def _get_ws(self):
289289
}
290290
connect_id = 31
291291

292-
self._ws = await websockets.connect("wss://api.traderepublic.com", ssl=ssl_context, extra_headers=extra_headers)
292+
self._ws = await websockets.connect(
293+
"wss://api.traderepublic.com", ssl=ssl_context, additional_headers=extra_headers
294+
)
293295
await self._ws.send(f"connect {connect_id} {json.dumps(connection_message)}")
294296
response = await self._ws.recv()
295297

0 commit comments

Comments
 (0)