When timeout is missing from elapi.yml, running a Python script that is using elAPI will fail and throw TypeError: an integer is required (got type Missing).
The following code:
from elapi.api import GETRequest
session = GETRequest()
teams = session("teams")
print(teams.json())
will throw:
Traceback (most recent call last):
File "/Users/culdesac/Workshop/try-elapi/try_teams.py", line 7, in <module>
teams = session("teams", endpoint_id=None)
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/elapi/api/api.py", line 278, in __call__
return super().__call__(
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/elapi/api/api.py", line 75, in __call__
response = self._make(*args, **kwargs)
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/elapi/api/api.py", line 262, in _make
return super().client.get(
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/httpx/_client.py", line 1041, in get
return self.request(
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/httpx/_client.py", line 814, in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/httpx/_client.py", line 901, in send
response = self._send_handling_auth(
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/httpx/_client.py", line 929, in _send_handling_auth
response = self._send_handling_redirects(
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/httpx/_client.py", line 966, in _send_handling_redirects
response = self._send_single_request(request)
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/httpx/_client.py", line 1002, in _send_single_request
response = transport.handle_request(request)
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/httpx/_transports/default.py", line 218, in handle_request
resp = self._pool.handle_request(req)
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/httpcore/_sync/connection_pool.py", line 262, in handle_request
raise exc
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/httpcore/_sync/connection_pool.py", line 245, in handle_request
response = connection.handle_request(request)
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/httpcore/_sync/connection.py", line 92, in handle_request
raise exc
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/httpcore/_sync/connection.py", line 69, in handle_request
stream = self._connect(request)
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/httpcore/_sync/connection.py", line 117, in _connect
stream = self._network_backend.connect_tcp(**kwargs)
File "/Users/culdesac/Workshop/try-elapi/.venv/lib/python3.9/site-packages/httpcore/_backends/sync.py", line 100, in connect_tcp
sock = socket.create_connection(
File "/Users/culdesac/.pyenv/versions/3.9.2/lib/python3.9/socket.py", line 828, in create_connection
sock.settimeout(timeout)
TypeError: an integer is required (got type Missing)
When
timeout
is missing fromelapi.yml
, running a Python script that is using elAPI will fail and throwTypeError: an integer is required (got type Missing)
.The following code:
will throw:
Originally discovered by @alexander-haller.