Skip to content

refactor(oocana): move string_hash to internal.py#459

Merged
leavesster merged 1 commit intomainfrom
refactor/move-string-hash-utils
Feb 2, 2026
Merged

refactor(oocana): move string_hash to internal.py#459
leavesster merged 1 commit intomainfrom
refactor/move-string-hash-utils

Conversation

@leavesster
Copy link
Contributor

Summary

  • Move string_hash() function from context.py to internal.py
  • Keep utility functions in a central location

Problem

string_hash() was defined at module level in context.py but is a general utility function that doesn't belong there.

Solution

Move to internal.py where other utility functions like random_string() are defined.

Test Plan

  • All existing tests pass
  • Import updated in context.py

Copilot AI review requested due to automatic review settings January 31, 2026 09:27
@coderabbitai
Copy link

coderabbitai bot commented Jan 31, 2026

Summary by CodeRabbit

发布说明

  • 重构
    • 优化了内部代码组织结构,将哈希计算工具函数进行了模块化整理,提升代码可维护性。无任何公开 API 变化,用户体验保持不变。

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

string_hashcontext.py 移至 internal.pycontext.py 不再包含本地实现,而是从 .internal 导入 string_hashinternal.py 新增 string_hash(text: str) -> str,使用 SHA-256 返回十六进制摘要。

Changes

Cohort / File(s) Summary
String hash refactor
oocana/oocana/context.py, oocana/oocana/internal.py
移除 context.py 中的本地 string_hash 实现并删除对 hashlib 的直接依赖;在 internal.py 中新增 string_hash(text: str) -> str(SHA-256 十六进制摘要),context.py 改为从 .internal 导入该函数。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed 标题完全符合要求的格式 <type>(<scope>): <subject>,准确描述了拉取请求的主要变更(将 string_hash 函数从 context.py 移动到 internal.py)。
Description check ✅ Passed 描述与变更集高度相关,清楚地说明了问题、解决方案和测试计划,确认所有现有测试都通过了。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the codebase by moving the string_hash() utility function from context.py to internal.py, where other utility functions are centralized. This improves code organization by grouping utility functions together.

Changes:

  • Moved string_hash() function definition from context.py to internal.py
  • Updated import in context.py to import string_hash from internal
  • Removed unused hashlib import from context.py

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
oocana/oocana/internal.py Added string_hash() function definition and hashlib import
oocana/oocana/context.py Removed string_hash() definition and hashlib import; updated import statement to include string_hash from internal

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 9 to 13
def string_hash(text: str) -> str:
"""
Generates a deterministic hash for a given string.
"""
return hashlib.sha256(text.encode('utf-8')).hexdigest()
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

The string_hash function is placed before the InternalAPI class, but the existing random_string utility function is defined after the class (line 40). For consistency, consider moving string_hash to after the InternalAPI class definition, near random_string, to keep all utility functions grouped together.

Copilot uses AI. Check for mistakes.
@leavesster leavesster changed the title refactor: move string_hash to internal.py refactor(oocana): move string_hash to internal.py Jan 31, 2026
The string_hash utility function was defined in context.py but belongs
with other utility functions in internal.py. This improves code
organization.
@leavesster leavesster force-pushed the refactor/move-string-hash-utils branch from 0f731f1 to 35f0dd7 Compare February 2, 2026 03:06
@leavesster leavesster merged commit a1ae5a0 into main Feb 2, 2026
8 checks passed
@leavesster leavesster deleted the refactor/move-string-hash-utils branch February 2, 2026 03:44
@oomol-bot oomol-bot mentioned this pull request Feb 2, 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.

1 participant