Skip to content

Fix code quality issues in InternVL2_5 ksana_plugin_model.py#60

Open
hobostay wants to merge 1 commit intoTencent:mainfrom
hobostay:fix-code-quality-issues
Open

Fix code quality issues in InternVL2_5 ksana_plugin_model.py#60
hobostay wants to merge 1 commit intoTencent:mainfrom
hobostay:fix-code-quality-issues

Conversation

@hobostay
Copy link
Copy Markdown

Summary

This PR fixes code quality issues in InternVL2_5/ksana_plugin_model.py.

Changes

  1. Replace bare except clause with specific ImportError exception

    • The original code used a bare except: clause (line 35)
    • Bare except catches all exceptions including SystemExit and KeyboardInterrupt
    • This is considered bad practice in Python (PEP 8)
    • Changed to except ImportError: which is appropriate for optional imports
  2. Remove duplicate IMG_CONTEXT_TOKEN constant definition

    • The constant IMG_CONTEXT_TOKEN was defined twice (lines 41 and 44)
    • Removed the redundant definition on line 44

Impact

  • Code quality: Follows Python best practices (PEP 8)
  • No functional changes: The behavior remains the same
  • Improved maintainability: Clearer intent and reduced redundancy

- Replace bare except clause with specific ImportError exception
  The bare except clause catches all exceptions including SystemExit
  and KeyboardInterrupt, which is considered bad practice.

- Remove duplicate IMG_CONTEXT_TOKEN constant definition
  The constant was defined twice on lines 41 and 44.

These changes improve code quality and follow Python best practices.
@tencent-adm
Copy link
Copy Markdown
Member

tencent-adm commented Mar 31, 2026

CLA assistant check
All committers have signed the CLA.

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