Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Algolia search depends on `typing` which is in Python3.7 standard library #422

Closed
fernando-mc opened this issue May 16, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@fernando-mc
Copy link
Contributor

commented May 16, 2019

  • Algolia Client Version: 2.0.1
  • Language Version: Python 3.7

Description

When using the algoliasearch library in a python3.7 environment it installs typing which causes some sort of conflict with the standard library.

Because the library is only required with version of Python 3.5 and below can you add that condition to the requirements file?

See this for context on the issue - python/typing#573

This is a solution implemented elsewhere:
MartinoMensio/allennlp@a7d7b8f

Steps To Reproduce

In my case this was actually frustrating me. I can reproduce this issue within an AWS python v3.7.3 runtime but not in my local python 3.7.3 runtime.

My steps to reproduce this involved:
Deploying an application with the algoliasearch dependency to the AWS Python 3.7 runtime.
Noting the stack traces pointing to the Algolia library and the typing library:

File "/var/task/typing.py", line 1004, in new
self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry'

I can open a PR for this fix if you think it would be fixed. At the moment I have to run some custom logic not to deploy the typing library with Algolia search.

@nunomaduro

This comment has been minimized.

Copy link
Member

commented May 16, 2019

I would appreciate a pull request to better understand the issue, thanks!

@fernando-mc

This comment has been minimized.

Copy link
Contributor Author

commented May 16, 2019

I'll put in the PR shortly. The issue can be reproduced with the following steps which roughly equate to how packages are handled in the AWS Lambda Python3.7 runtime.

This assumes a Python 3.7.x version:

  1. Install packages in the current directory with a command like pip3 install algoliasearch -t .
  2. Then enter the Python3.7 interpreter python3
  3. Run from algoliasearch.search_client import SearchClient

Then you will see the following stack trace:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/fernando/Desktop/test/algoliasearch/search_client.py", line 5, in <module>
    from typing import Optional, Union, List
  File "/Users/fernando/Desktop/test/typing.py", line 1356, in <module>
    class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
  File "/Users/fernando/Desktop/test/typing.py", line 1004, in __new__
    self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry'
@nunomaduro

This comment has been minimized.

Copy link
Member

commented May 21, 2019

This is was been fixed on the version v2.0.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.