algolia / algoliasearch-client-python

⚡️ A fully-featured and blazing-fast Python API client to interact with Algolia.
https://www.algolia.com/doc/api-client/getting-started/install/python/?language=python
MIT License
196 stars 67 forks source link

Unable to initialize SearchClient on Python 3.11 #549

Closed nickolaj-jepsen closed 1 year ago

nickolaj-jepsen commented 1 year ago

Description

When trying to initialize the SearchClient on Python 3.11 (with aiohttp installed to enable async requests), the following exception occurs:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.11/site-packages/algoliasearch/search_client.py", line 55, in create
    return SearchClient.create_with_config(config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/algoliasearch/search_client.py", line 67, in create_with_config
    from algoliasearch.search_client_async import SearchClientAsync
  File "/usr/local/lib/python3.11/site-packages/algoliasearch/search_client_async.py", line 8, in <module>
    from algoliasearch.http.transporter_async import TransporterAsync
  File "/usr/local/lib/python3.11/site-packages/algoliasearch/http/transporter_async.py", line 6, in <module>
    from algoliasearch.http.requester_async import RequesterAsync
  File "/usr/local/lib/python3.11/site-packages/algoliasearch/http/requester_async.py", line 10, in <module>
    class RequesterAsync(Requester):
  File "/usr/local/lib/python3.11/site-packages/algoliasearch/http/requester_async.py", line 16, in RequesterAsync
    @asyncio.coroutine  # type: ignore
     ^^^^^^^^^^^^^^^^^
AttributeError: module 'asyncio' has no attribute 'coroutine'. Did you mean: 'coroutines'?

It seems like it's related to the deprecation of the @asyncio.coroutine decorator, as described here: https://docs.python.org/3.10/library/asyncio-task.html#asyncio.coroutine

Steps To Reproduce

Install the python 3.11 interpreter, or use a python 3.11 docker image (I used this command to test the issue $ docker run --rm -it python:3.11 bash

Then install algoliaclient and aiohttp

$ pip install algoliasearch==2.6.2 aiohttp==3.8.3

And the run the following in a python shell:

from algoliasearch.search_client import SearchClient

client = SearchClient.create('xxx', 'xxx')
shortcuts commented 1 year ago

hey it indeed support up to python 3.9, there was this community PR opened but it got closed: https://github.com/algolia/algoliasearch-client-python/pull/548

feel free to re-open I'll make sure to review!

rorosan commented 1 year ago

i do have the same problem as well @shortcuts :) If you could review and update the library that would be awesome !

salomvary commented 1 year ago

Hey folks, my attempt on fixing the issue in this pull request: https://github.com/algolia/algoliasearch-client-python/pull/551

paul-finary commented 1 year ago

Thanks for the PR @salomvary ! I'm also interested in having support for 3.11.

danpitchup commented 1 year ago

Is there any news on this ticket? We're blocked from upgrading our application to Python 3.11 until it's ready.

proteusvacuum commented 1 year ago

Hello, just wanted to add another voice that we are also interested in having this fixed. Please let me know if there is some way I can help!

shortcuts commented 1 year ago

Hey, I'm back from holidays and just added https://github.com/algolia/algoliasearch-client-python/pull/553 to my sprint, will try to release before tomorrow.

Sorry for the wait everyone!

edit: took a bit longer than expected, looking to fix the issues

shortcuts commented 1 year ago

doing some cleanup etc. and will release the new major