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

Make SearchClient more pythonic #535

Closed
kai687 opened this issue Sep 20, 2021 · 2 comments
Closed

Make SearchClient more pythonic #535

kai687 opened this issue Sep 20, 2021 · 2 comments
Labels
Fixed in v4 see https://github.com/algolia/api-clients-autom

Comments

@kai687
Copy link
Contributor

kai687 commented Sep 20, 2021

  • Algolia Client Version: 2.5.0
  • Language Version: Python 3.8

Description

It's a small thing, but I'm so used to instantiating Python objects like this:

client = SearchClient(app_id, api_key)

that I didn't even think about using SearchClient.create(..). It took me some time to figure this out, because by chance, the SearchClient.__init__ method accepts two arguments and there's no validation.

Steps To Reproduce

For example:

from algoliasearch.search_client import SearchClient

client = SearchClient('APP_ID', 'API_KEY')
client.get_api_key('API_KEY')

throws a traceback because self._transporters is now an instance of str.

Expected Behavior

Ideally, the SearchClient object should behave like other Python objects, with user-provided arguments to the __init__ method. If that won't work, can it be an empty __init__ method without user arguments, and you assign the transporter and config attributes in the create method or elsewhere?

@morganpartee
Copy link

Hahaha, holy crap, thanks. That was my problem.

@shortcuts shortcuts added the Fixed in v4 see https://github.com/algolia/api-clients-autom label Jan 5, 2024
@millotp
Copy link
Contributor

millotp commented Sep 5, 2024

this is fixed in v4

@millotp millotp closed this as completed Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in v4 see https://github.com/algolia/api-clients-autom
Projects
None yet
Development

No branches or pull requests

4 participants