algoliasearch-client-python icon indicating copy to clipboard operation
algoliasearch-client-python copied to clipboard

Distribute type hints (PEP 561)

Open pcorpet opened this issue 4 years ago • 0 comments
trafficstars

  • Algolia Client Version: 2.5.0
  • Language Version: 3.9

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"

pcorpet avatar Aug 06 '21 21:08 pcorpet