Skip to content

Commit

Permalink
Improved error handling for iter and aiter for paginatedattrdict
Browse files Browse the repository at this point in the history
  • Loading branch information
fourjr committed Nov 15, 2018
1 parent b6fde31 commit cf5b755
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
All notable changes to this project will be documented in this file.

## [Unreleased]
No changes yet

### Added
- RuntimeError if you were calling the wrong method (iter/aiter) on an inappropriate client (i.e. async client -> iter/blocking client -> aiter)

## [4.0.0] - 11/11/2018
### Added
Expand Down
4 changes: 4 additions & 0 deletions clashroyale/official_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ def __getitem__(self, item):

@async_generator
async def __aiter__(self):
if not self.client.is_async:
raise RuntimeError('Calling __aiter__ on an asynchronus client. Use :for: not :async for:')
while True:
index = 0
for _ in range(index, len(self.raw_data)):
Expand All @@ -169,6 +171,8 @@ async def __aiter__(self):
break

def __iter__(self):
if self.client.is_async:
raise RuntimeError('Calling __iter__ on an asynchronus client. Use :async for: not :for:')
while True:
index = 0
for _ in range(index, len(self.raw_data)):
Expand Down

0 comments on commit cf5b755

Please sign in to comment.