Skip to content

fix: Add default value to _print function parameter#134

Merged
wangxingjun778 merged 2 commits intomodelscope:mainfrom
xerrors:main
Apr 1, 2026
Merged

fix: Add default value to _print function parameter#134
wangxingjun778 merged 2 commits intomodelscope:mainfrom
xerrors:main

Conversation

@xerrors
Copy link
Copy Markdown
Contributor

@xerrors xerrors commented Mar 31, 2026

Summary

  • Fix _print function to have a default empty string value for msg parameter
  • This resolves an issue where calling _print() without arguments would fail at runtime

Problem

The _print function in web_launcher.py required a msg parameter with no default value:

def _print(msg: str):
"""Print with flush for real-time output."""
print(msg, flush=True)

But it was being called without arguments in some code paths, causing the application to crash on startup.

_print()
_print("=" * 60)
_print("✅ Development servers running!")
_print("=" * 60)
_print(f" Frontend: http://localhost:{frontend_port}")
_print(f" Backend: http://localhost:{backend_port}")
_print(f" API Docs: http://localhost:{backend_port}/docs")
_print("=" * 60)
_print()
_print("Press Ctrl+C to stop all services.")

Solution

Added default empty string to the parameter:

def _print(msg: str = ""):  # Now has default value

Test plan

  • Verified the script launches without errors
  • _print() can now be called without arguments

…essage parameter defaults to an empty string
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the _print utility function in web_launcher.py to allow calling it without arguments by setting a default value for the msg parameter. Feedback suggests adding an explicit -> None return type hint to the function signature to improve type safety and maintain consistency with the rest of the codebase.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@wangxingjun778 wangxingjun778 merged commit c99bc95 into modelscope:main Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants