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

Distribute type hints (PEP 561) #533

Open pcorpet opened 3 years ago

pcorpet commented 3 years ago

Description

The library's code contains type hints (great!) but those are not advertised so our code doesn't use them (it doesn't even look for them). According to PEP 561, you would need to package and distribute a py.typed file with your library for those types to be used easily.

Steps To Reproduce

Write some python code based on algoliasearch.

In requirements.txt:

algoliasearch==2.5.0
mypy==0.910

In the code:

from algoliasearch import search_client

search_client.SearchClient.create(
    os.getenv('ALGOLIA_APP_ID', ''),
    os.getenv('ALGOLIA_API_KEY', '')).init_index(3)

Running mypy doesn't yell, where it should actually fail with the following error:

error: Argument 1 to "init_index" of "SearchClient" has incompatible type "int"; expected "str"