diff --git a/CHANGELOG.md b/CHANGELOG.md index 48f7323..3e982a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/clashroyale/official_api/models.py b/clashroyale/official_api/models.py index 8771abe..3cc76d5 100644 --- a/clashroyale/official_api/models.py +++ b/clashroyale/official_api/models.py @@ -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)): @@ -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)):