code-to10 v6 A6: fix mypy cost.py:551 tuple annotation
- model_breakdown inferred params as a 1-tuple from the first branch, so params + (month,) was tuple[Any] vs tuple[Any, str]. Annotate params as bare tuple (tuple[Any, ...]) before branching. - Annotation only: the () initializer is never used (if/elif/else always overwrites it), runtime semantics unchanged. - mypy cloud/: 0 errors in 94 files (was 1 error); ruff clean; cost tests 39 pass. (cherry picked from commit a9fd0692361e8169554413b725c81135be2c5525)
This commit is contained in:
1 parent
8b3d80670d
commit
324c19686c
1 file changed
+6
@@ -536,6 +536,12 @@ class CostStore:
|
|||||||
raise ValueError(
|
raise ValueError(
|
||||||
"exactly one of task_id, project_id, creator_id required")
|
"exactly one of task_id, project_id, creator_id required")
|
||||||
join = ""
|
join = ""
|
||||||
|
# 类型标注而已(A6):首分支会把 params 推断成单元素元组,
|
||||||
|
# 导致下面 params + (month,) 报 tuple[Any] vs tuple[Any, str];
|
||||||
|
# 标注成裸 tuple(即 tuple[Any, ...])后三分支与拼接均合法。
|
||||||
|
# 初值 () 永不被使用——if/elif/else 三分支必居其一重写它,
|
||||||
|
# 运行时语义不变。
|
||||||
|
params: tuple = ()
|
||||||
if task_id is not None:
|
if task_id is not None:
|
||||||
where, params = "c.task_id = ?", (task_id,)
|
where, params = "c.task_id = ?", (task_id,)
|
||||||
elif project_id is not None:
|
elif project_id is not None:
|
||||||
|
|||||||
Reference in new issue
Block a user