fix: restore star context typing#8659
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors astrbot/core/star/base.py by replacing the local _ContextLike Protocol with the concrete Context class, which is imported conditionally under TYPE_CHECKING to prevent circular imports. The context attribute on the Star class is now explicitly typed with Context. There are no review comments, and I have no feedback to provide.
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.
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Since
Contextis only imported underTYPE_CHECKING, make sure this module either usesfrom __future__ import annotationsor changescontext: Context/def __init__(..., context: Context, ...)to use string annotations (e.g.,"Context") to avoid aNameErrorat runtime.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Since `Context` is only imported under `TYPE_CHECKING`, make sure this module either uses `from __future__ import annotations` or changes `context: Context` / `def __init__(..., context: Context, ...)` to use string annotations (e.g., `"Context"`) to avoid a `NameError` at runtime.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Summary
Tests
Summary by Sourcery
Restore Star context attribute and constructor typing to use the real Context type while preserving existing runtime import behavior.
Bug Fixes:
Enhancements: