-
Notifications
You must be signed in to change notification settings - Fork 856
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
chore: update return type to Optional[str] #982
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.
Thanks!
@@ -57,13 +57,13 @@ def __init__(self, model_aliases: List[ModelAlias]): | |||
self.alias_to_provider_id_map[alias_obj.llama_model] = alias_obj.provider_model_id | |||
self.provider_id_to_llama_model_map[alias_obj.provider_model_id] = alias_obj.llama_model | |||
|
|||
def get_provider_model_id(self, identifier: str) -> str: | |||
def get_provider_model_id(self, identifier: str) -> Optional[str]: | |||
if identifier in self.alias_to_provider_id_map: |
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.
whole thing could be just self.alias_to_provider_id_map.get(identifier, None)
I think.
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.
Thanks for the suggestion! @ashwinb PTAL
Updated the return type of the methods `get_provider_model_id` and `get_llama_model` in the `ModelRegistryHelper` class to `Optional[str]` to indicate that they may return a string or None when no match is found. This change improves the clarity of the methods' behavior and supports better type safety. Replaced explicit `if-else` checks with `dict.get()` for cleaner code. Signed-off-by: Sébastien Han <seb@redhat.com>
b3fa9ae
to
787e78d
Compare
What does this PR do?
Updated the return type of the methods
get_provider_model_id
andget_llama_model
in theModelRegistryHelper
class toOptional[str]
to indicate that they may return a string or None when no match is found. This change improves the clarity of the methods' behavior and supports better type safety.Signed-off-by: Sébastien Han seb@redhat.com
Test Plan
Please describe:
Sources
Please link relevant resources if necessary.
Before submitting
Pull Request section?