cgrok / clashroyale

Async + Sync wrapper for royaleapi.com and the CR official API
MIT License
47 stars 19 forks source link

AttributeError: __enter__ when trying sync example from stable #36

Open Amleto opened 4 years ago

Amleto commented 4 years ago

I used python 3.6, clashroyale 4.0.1, in win 10 console and pasted the sync example lines, except adding my api token. I ran into the following error,

>>> profile = client.get_player('#8l9l9gl')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\utils.py", line 35, in wrapper
    return func(*new_args, **new_kwargs)
  File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\client.py", line 248, in get_player
    return self._get_model(url, FullPlayer, timeout=timeout)
  File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\client.py", line 231, in _get_model
    raise e
  File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\client.py", line 224, in _get_model
    data, cached, ts, resp = self._request(url, **params)
  File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\client.py", line 178, in _request
    method, url, timeout=timeout, headers=self.headers, params=params, json=json_data
AttributeError: __enter__
Amleto commented 4 years ago

believe this is due to requests lib version... I had 2.17, upgraded to 2.20 and this went away, hence you need to put a minimum version in the requirements.

gogaz commented 4 years ago

Feel free to open a new PR, also make sure to read CONTRIBUTING.md before submitting it 😉