Skip to content

fix(gate-quality): trust_engine_v2 类型注解用 TYPE_CHECKING 导入 - #307

Merged
frankiehot-tech merged 1 commit into
mainfrom
fix/trust-engine-v2-typing
Aug 8, 2026
Merged

fix(gate-quality): trust_engine_v2 类型注解用 TYPE_CHECKING 导入#307
frankiehot-tech merged 1 commit into
mainfrom
fix/trust-engine-v2-typing

Conversation

@frankiehot-tech

Copy link
Copy Markdown
Contributor

摘要

gate-quality 的 ruff check src/maref src/maref_lite 在 CI 上仍失败,此前(PR #302)只修了 __init__.py 的 I001,但完整树检查发现 3 个 pre-existing 错误全部来自 src/maref/recursive/trust_engine_v2.py

  • F821 at 94:55 — def to_audit_record(...) -> UnifiedAuditRecord 注解中 UnifiedAuditRecord 未定义(lazy import 仅在函数体内)
  • F821 at 148:37 — def __init__(self, audit_store: UnifiedAuditStore | None = None) 注解中 UnifiedAuditStore 未定义
  • I001 at 1:1 — @dataclass 前缺双空行(import 块与顶层代码分隔)

修复

  • from typing import TYPE_CHECKING, Any + if TYPE_CHECKING: 块引入两个类型(运行时惰性导入保留,无循环 import 风险)
  • @dataclass 前补双空行

验证

  • ruff check src/maref src/maref_lite → All checks passed!
  • ruff format --check 目标文件 → already formatted
  • 未新增 /Volumes/ 硬编码路径(No hardcoded paths 步骤不受影响)
  • 运行时行为不变:TYPE_CHECKING 为 False 时不执行导入,原函数体内惰性导入保留

- F821: to_audit_record/__init__ 注解中的 UnifiedAuditRecord/UnifiedAuditStore
  此前仅在函数体内惰性导入,注解求值时未定义 → 移到 TYPE_CHECKING 块
- I001: @DataClass 前补双空行,满足 import 块与顶层代码分隔
@cla-assistant

cla-assistant Bot commented Aug 8, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Athena seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant

cla-assistant Bot commented Aug 8, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Athena seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@frankiehot-tech
frankiehot-tech marked this pull request as ready for review August 8, 2026 02:53
@frankiehot-tech
frankiehot-tech requested a review from a team as a code owner August 8, 2026 02:53
@frankiehot-tech
frankiehot-tech merged commit 5cbe7ca into main Aug 8, 2026
14 of 18 checks passed
@frankiehot-tech
frankiehot-tech deleted the fix/trust-engine-v2-typing branch August 8, 2026 02:53
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