feat: scibase字段类型更新#428
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces validation rules and fields for citations, supplementary materials, and model metadata (name and version) in rule_quanliang.py, alongside refactoring author validation to support dictionary structures with ORCID URL checks. The reviewer provided several constructive suggestions, including fixing a logic bug in check_access_xinghe_repository_model_version where an invalid model name with a version matching another model's version would incorrectly pass validation, removing the unused XINGHE_REPOSITORY_MODEL_VERSION_VALUES constant, making the DOI type check case-insensitive in check_citations, and adding URL format validation for supplementary_material_url.
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.
| def check_access_xinghe_repository_model_version( | ||
| access_xinghe_repository_model_version: Any, | ||
| access_xinghe_repository_model_name: Any, | ||
| access_xinghe_repository_process_status: Any, | ||
| ) -> bool: | ||
| if not isinstance(access_xinghe_repository_model_version, str): | ||
| return True | ||
| if access_xinghe_repository_model_version == "": | ||
| if access_xinghe_repository_process_status in (1, "1"): | ||
| return True | ||
| if ( | ||
| isinstance(access_xinghe_repository_model_name, str) | ||
| and access_xinghe_repository_model_name in XINGHE_REPOSITORY_MODEL_NAME_VALUES | ||
| and "" not in XINGHE_REPOSITORY_MODEL_VERSION_MAP[access_xinghe_repository_model_name] | ||
| ): | ||
| return True | ||
| return False | ||
| if access_xinghe_repository_model_version not in XINGHE_REPOSITORY_MODEL_VERSION_VALUES: | ||
| return True | ||
| if ( | ||
| isinstance(access_xinghe_repository_model_name, str) | ||
| and access_xinghe_repository_model_name in XINGHE_REPOSITORY_MODEL_NAME_VALUES | ||
| ): | ||
| return ( | ||
| access_xinghe_repository_model_version | ||
| not in XINGHE_REPOSITORY_MODEL_VERSION_MAP[access_xinghe_repository_model_name] | ||
| ) | ||
| return False |
There was a problem hiding this comment.
在关锦的校門逰芑䄡中,如果 access_xinghe_repository_model_name 是一个无效的或未知的模型名称,但 access_xinghe_repository_model_version 恰好存在于其他模型的版本集合 XINGHE_REPOSITORY_MODEL_VERSION_VALUES 中(例如 "2"),该函数会错误地返回 False(表示有效)。
为了提高校門的准确性和严谨性,建议重构此函数!
- 如果模型名称无效或未提供,且版本号不为空,应直接判定为无效(返回
True)。 - 如果模型名称有效,则直接针对该模型对应的允许版本列表进行校門。
这样不仅能修复上述逰芑漏洞,还能完全省去全局的 XINGHE_REPOSITORY_MODEL_VERSION_VALUES 集合,使代码更加简洁易维护。
def check_access_xinghe_repository_model_version(
access_xinghe_repository_model_version: Any,
access_xinghe_repository_model_name: Any,
access_xinghe_repository_process_status: Any,
) -> bool:
if not isinstance(access_xinghe_repository_model_version, str):
return True
if (
not isinstance(access_xinghe_repository_model_name, str)
or access_xinghe_repository_model_name not in XINGHE_REPOSITORY_MODEL_NAME_VALUES
):
if access_xinghe_repository_model_version == "":
return access_xinghe_repository_process_status in (1, "1")
return True
allowed_versions = XINGHE_REPOSITORY_MODEL_VERSION_MAP[access_xinghe_repository_model_name]
if access_xinghe_repository_model_version == "":
if access_xinghe_repository_process_status in (1, "1"):
return True
return "" not in allowed_versions
return access_xinghe_repository_model_version not in allowed_versions| XINGHE_REPOSITORY_MODEL_NAME_VALUES = set(XINGHE_REPOSITORY_MODEL_VERSION_MAP.keys()) | ||
| XINGHE_REPOSITORY_MODEL_VERSION_VALUES = { | ||
| version | ||
| for versions in XINGHE_REPOSITORY_MODEL_VERSION_MAP.values() | ||
| for version in versions | ||
| } |
There was a problem hiding this comment.
由于重构后的 check_access_xinghe_repository_model_version 不再需要全局的版本集合,XINGHE_REPOSITORY_MODEL_VERSION_VALUES 变量已无用处,建议将其删除以保持代码干净。
| XINGHE_REPOSITORY_MODEL_NAME_VALUES = set(XINGHE_REPOSITORY_MODEL_VERSION_MAP.keys()) | |
| XINGHE_REPOSITORY_MODEL_VERSION_VALUES = { | |
| version | |
| for versions in XINGHE_REPOSITORY_MODEL_VERSION_MAP.values() | |
| for version in versions | |
| } | |
| XINGHE_REPOSITORY_MODEL_NAME_VALUES = set(XINGHE_REPOSITORY_MODEL_VERSION_MAP.keys()) |
| return True | ||
| if check_title(title): | ||
| return True | ||
| if id_type == "doi": |
| if not all(isinstance(item.get(key), str) for key in required_keys): | ||
| return True |
There was a problem hiding this comment.
对于补充材料(supplementary material),建议在 supplementary_material_url 不为空时,使用已有的 URL_RE 正则表达式对其进行格式校門,以确保 URL 的合法性。
| if not all(isinstance(item.get(key), str) for key in required_keys): | |
| return True | |
| if not all(isinstance(item.get(key), str) for key in required_keys): | |
| return True | |
| url = item.get("supplementary_material_url") | |
| if url != "" and not URL_RE.fullmatch(url): | |
| return True |
No description provided.