Skip to content

Commit d9c6b0d

Browse files
committed
self._raw.get('results', []) returns None, not [] which breaks
when we try to iterate it. writing it like this will ensure that the user will receive an empty response (empty Aggs list) which will not raise TypeError: 'NoneType' object is not iterable
1 parent 0605371 commit d9c6b0d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

alpaca_trade_api/polygon/entity.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,14 @@ def __init__(self, raw):
9393
])
9494

9595
def _raw_results(self):
96-
return self._raw.get('results', [])
96+
results = self._raw.get('results')
97+
if not results:
98+
# this is not very pythonic but it's written like this because
99+
# the raw response for empty aggs was None, and this:
100+
# self._raw.get('results', []) returns None, not [] which breaks
101+
# when we try to iterate it.
102+
return []
103+
return results
97104

98105
def rename_keys(self):
99106
colmap = {

0 commit comments

Comments
 (0)