-
Notifications
You must be signed in to change notification settings - Fork 90
Keep the code object oriented everywhere #604
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
Comments
There are several ways to go about this, none right or wrong just different choices. The way I chose to go about it is the Out of the options you have I would chose option one because a class with only static methods implies the class isn't needed (gain just choices not right or wrong). It would also mean not needing to pass the connection information every time if the |
In your suggestion, the user has to import the Task module to be able to use its functions? from meilisearch_python_async.task import get_task
get_task(...) |
Yes, you would have to import it. |
By making this choice, are we not making the usage of the library more complex in favor of a certain code architecture? |
In my opinion no, but that doesn't mean my opinion is everyone's opinion or the only correct opinion 🙂. The reason I made this choice is a task is its own thing. It isn't related to a |
662: Object oriented code r=alallema a=Azanul # Pull Request ## Related issue Fixes #604 ## What does this PR do? - Converts root level functions to class methods ## PR checklist Please check if your PR fulfills the following requirements: - [X] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [X] Have you read the contributing guidelines? - [X] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: Azanul <[email protected]> Co-authored-by: Azanul Haque <[email protected]> Co-authored-by: Amélie <[email protected]>
in meilisearch/tasks.py we create root level functions. This is the only file in this project where we do not do object-oriented programming.
For example, we call
get_task
in theget_task
methodmeilisearch-python/meilisearch/client.py
Lines 402 to 423 in ebfb0bb
This leads to:
get_task
come from? Is it an infinite loop?Suggestion:
Create a
TaskHandler
class inmeilisearch/task.py
that initializes the necessary information in its instance:add
get_task
andget_tasks
as a method of this class. Remove the requiredConfig
parameter.import the
TaskHandler
in the client file.in the client method
get_task
, call the function the following way:Another solution would be to make all these functions static, in which way they would keep their current function prototype, there would be no need for an initialized and it will be called like this:
What do you think about this @sanders41 ?
The text was updated successfully, but these errors were encountered: