benjhar / JokeAPI-Python

An API Wrapper for Sv443's JokeAPI
GNU General Public License v3.0
33 stars 9 forks source link

README example broken: TypeError: object Jokes can't be used in 'await' expression #14

Closed yonas closed 2 years ago

yonas commented 2 years ago
$ ./joke.py
Sv443's JokeAPI
Traceback (most recent call last):
  File "./joke.py", line 16, in <module>
    asyncio.run(print_joke())
  File "/usr/local/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "./joke.py", line 7, in print_joke
    j = await Jokes()  # Initialise the class
TypeError: object Jokes can't be used in 'await' expression
benjhar commented 2 years ago

The documentation examples are meant to be used with the most recent version, currently 1.0.3. You are running 0.2.11, which is over a year out of date. Not quite sure how it happened that pip installed such an old version.

Could you try uninstalling jokeapi with pip, and then running sudo pip install jokeapi=="1.0.3"?

yonas commented 2 years ago

Thanks. Specifying the version gives me this error:

$ sudo pip install jokeapi=="1.0.3"
ERROR: Could not find a version that satisfies the requirement jokeapi==1.0.3
ERROR: No matching distribution found for jokeapi==1.0.3

It looks like the latest jokeapi ( >= 1.0.0 ) requires Python >=3.9, <4.0. I've got Python 3.8 installed.

What feature are you using that requires 3.9? Can it be easily translated to 3.8?

benjhar commented 2 years ago

Honestly, the decision to use 3.9 was somewhat arbitrary. I've tested the code and it works as far back as 3.7, and I'll change the build files accordingly.

benjhar commented 2 years ago

You'll now be able to install 1.0.4 through pip, and the example code runs without issue.

yonas commented 2 years ago

It works, thanks! :tada: