Skip to content

Commit

Permalink
Fix Any return type issues in term_color.py and import_utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
openhands-agent committed Feb 18, 2025
1 parent 71564ba commit 01868f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions openhands/utils/import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
T = TypeVar('T')


def import_from(qual_name: str):
def import_from(qual_name: str) -> object:
"""Import the value from the qualified name given"""
parts = qual_name.split('.')
module_name = '.'.join(parts[:-1])
Expand All @@ -18,5 +18,6 @@ def get_impl(cls: Type[T], impl_name: str | None) -> Type[T]:
if impl_name is None:
return cls
impl_class = import_from(impl_name)
assert cls == impl_class or issubclass(impl_class, cls)
assert isinstance(impl_class, type), f"Expected a class, got {type(impl_class)}"
assert cls == impl_class or issubclass(impl_class, cls), f"Expected a subclass of {cls}, got {impl_class}"
return impl_class
4 changes: 3 additions & 1 deletion openhands/utils/term_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ def colorize(text: str, color: TermColor = TermColor.WARNING) -> str:
Returns:
str: Colored text
"""
return colored(text, color.value)
result = colored(text, color.value)
assert isinstance(result, str)
return result

0 comments on commit 01868f1

Please sign in to comment.