Skip to content

[WIP] Refactor #225

Open
tastelikefeet wants to merge 11 commits into
modelscope:mainfrom
tastelikefeet:feat/refactor-1
Open

[WIP] Refactor #225
tastelikefeet wants to merge 11 commits into
modelscope:mainfrom
tastelikefeet:feat/refactor-1

Conversation

@tastelikefeet

Copy link
Copy Markdown
Collaborator

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support
  • Refactor

PR information

Write the detail information belongs to this PR.

Experiment results

Paste your experiment result here(if needed).

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

Copy link
Copy Markdown
Contributor

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 cleans up unused imports across several files, including removing time in manager.py, os in mixin.py, and various types in cli.py. It also removes from __future__ import annotations from cli.py and quotes the ConfigRegistry type annotation as a result. The review feedback points out that removing from __future__ import annotations will break compatibility with Python < 3.10 due to the use of PEP 604 union types and PEP 585 generic collections. It is recommended to restore this import, which also allows using ConfigRegistry directly without quotes.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/twinkle/cli/cli.py
# Copyright (c) ModelScope Contributors. All rights reserved.
from __future__ import annotations

import os

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Removing from __future__ import annotations will break compatibility with Python < 3.10 because of the use of PEP 604 union types (e.g., str | None) and PEP 585 generic collections (e.g., list[str]) in type annotations. Additionally, keeping it enables postponed evaluation of annotations, allowing forward references (like ConfigRegistry) to be used without enclosing them in quotes. Please keep this import.

Suggested change
import os
from __future__ import annotations
import os

Comment thread src/twinkle/cli/cli.py
"""Reads os.environ; recognizes TWINKLE_ prefix and any key known to the registry."""

def __init__(self, registry: ConfigRegistry):
def __init__(self, registry: 'ConfigRegistry'):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

With from __future__ import annotations restored, you can use ConfigRegistry directly as a type annotation without enclosing it in quotes.

Suggested change
def __init__(self, registry: 'ConfigRegistry'):
def __init__(self, registry: ConfigRegistry):

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.

1 participant