-
Notifications
You must be signed in to change notification settings - Fork 90
Update the return type of methods #676
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much @sanders41 for this PR ❤️, it's a huge job! 🔥 🔥 🔥
and I'm really happy to see it done 😄
I have added some comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last question!
class KeyUpdate(CamelBase): | ||
key: str | ||
name: Optional[str] = None | ||
description: Optional[str] = None | ||
actions: Optional[List[str]] = None | ||
indexes: Optional[List[str]] = None | ||
expires_at: Optional[datetime] = None | ||
|
||
class Config: | ||
json_encoders = { | ||
datetime: lambda v: None | ||
if not v | ||
else f"{str(v).split('.', maxsplit=1)[0].replace(' ', 'T')}Z" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly this class is only used for the return of the update_key method so why not use it directly Key? We can keep this class to provide a Class to update Key like:
class KeyUpdate(CamelBase):
name: str = None
description: str = None
def update_key(self, key_or_uid: str, options: KeyUpdate) -> Key:
But I'm not sure it's worth it. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a mistake, I should have used Key
for the return. What I use KeyUpdate
for is exactly what you described. The disadvantage is the user has to import KeyUpdate
, but the advantage is the user knows exactly what to send.
I think an argument could be made for both options. I'll let you make the call if you want me to change options
to KeyUpdate
, or if you want me to remove the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion on this. I tend to agree with you, I find it easier for the user to keep the option. The only advantage of using a KeyUpdate
is that there is no risk of making a mistake on how to update the key due to the Strong guidance.
Let's leave it as it is I think it's fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much @sanders41 this is perfect! 🔥 🔥 🔥
LGTM! ✨
class KeyUpdate(CamelBase): | ||
key: str | ||
name: Optional[str] = None | ||
description: Optional[str] = None | ||
actions: Optional[List[str]] = None | ||
indexes: Optional[List[str]] = None | ||
expires_at: Optional[datetime] = None | ||
|
||
class Config: | ||
json_encoders = { | ||
datetime: lambda v: None | ||
if not v | ||
else f"{str(v).split('.', maxsplit=1)[0].replace(' ', 'T')}Z" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion on this. I tend to agree with you, I find it easier for the user to keep the option. The only advantage of using a KeyUpdate
is that there is no risk of making a mistake on how to update the key due to the Strong guidance.
Let's leave it as it is I think it's fine
bors merge |
Build succeeded:
|
693: Update version for the next release (v0.25.0) r=alallema a=alallema ##⚠️ Breaking changes * Update the return type of methods (#676) `@sanders41` ## 🚀 Enhancements * Transform all the `task` methods to a `TaskHandler` class (#662) `@Azanul` Thanks again to `@Azanul,` `@alallema,` `@brunoocasali` and `@sanders41!` 🎉 Co-authored-by: alallema <[email protected]>
Pull Request
Related issue
Fixes #610
Potentially fixes #449
What does this PR do?
TaskInfo
but I went ahead and updated them anyways because they are part of Add more precise typing #449PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!