fix(dupont): insight.detail 叙述段字面 None 收口(表现层 _fmt_val,仅文案)
ci/woodpecker/push/main Pipeline failed

- 恒等式叙述段 5 处裸 f-string 插值(三因子 value / ROE / identity.diff)改走 _fmt_val:
  None → 「-」(与同段四列 _fmt 同族),有值原样输出(不经 :.2f,保证有值路径逐字节不变)
- 结构化字段 roe / factors[*].value / identity.diff 仍为 null;check_identity 语义、dupont_basis.py 未改
- 基线 origin/main acf179a;本单零生产写(不推远端/不同步部署树/不重启/不连库)
This commit is contained in:
wecom-fullstack
2026-10-06 23:36:06 +08:00
parent acf179a199
commit a48a116e06
+8 -3
View File
@@ -2418,15 +2418,20 @@ def get_dupont_analysis(
# 存量/流量缺失时 raw 值为 None(如博海存量仅到区间外)⇒ 显式「-」,不得 None 格式化
return "-" if v is None else f"{v:.2f}"
def _fmt_val(v):
# 叙述段(恒等式三因子 / ROE / 偏差)表现层口径:缺失同族显式「-」;
# 有值时**原样输出**(不经 :.2f,保证有值路径逐字节不变)。
return "-" if v is None else v
detail = (f"{label}口径(流量累计 {win['period_start']}~{win['period_end']},"
f"存量{'平均' if cur['basis'] == 'average' else '期末回落'}"
f"{',年化 ×12/' + str(win['months']) if annualize else ',非年化'}):"
f"净利润 {_fmt(cur['raw']['net_profit'])}万 / 营业收入 {_fmt(cur['raw']['revenue'])}万 / "
f"平均总资产 {_fmt(cur['raw']['total_assets'])}万 / 平均净资产 {_fmt(cur['raw']['equity'])}万;"
f"ROE = {factors['net_profit_margin']['value']}% × {factors['asset_turnover']['value']} × "
f"{factors['equity_multiplier']['value']} = {None if roe_exact is None else round(roe_exact, 2)}%"
f"ROE = {_fmt_val(factors['net_profit_margin']['value'])}% × {_fmt_val(factors['asset_turnover']['value'])} × "
f"{_fmt_val(factors['equity_multiplier']['value'])} = {_fmt_val(None if roe_exact is None else round(roe_exact, 2))}%"
f"(恒等式 {'通过' if identity.get('status') == 'pass' else identity.get('status')},"
f"偏差 {identity.get('diff')} ≤ 容差 {identity.get('tolerance')})")
f"偏差 {_fmt_val(identity.get('diff'))} ≤ 容差 {identity.get('tolerance')})")
if cur["basis_fallback"]:
detail += f"|⚠️ {cur['basis_fallback_reason']}(basis_fallback=true)"