{
  "id": "python/pytest-parametrize-ids-type-error",
  "signature": "TypeError: ids must be a list of strings or callables, got <class 'int'>",
  "signature_zh": "类型错误：ids 必须是字符串列表或可调用对象，得到 <class 'int'>",
  "regex": "TypeError:\\ ids\\ must\\ be\\ a\\ list\\ of\\ strings\\ or\\ callables,\\ got\\ <class\\ 'int'>",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "在 pytest.mark.parametrize 中提供了非字符串类型的 ids 参数，pytest 无法生成测试 ID。",
  "root_cause_type": "generic",
  "root_cause_zh": "在 pytest.mark.parametrize 中提供了非字符串类型的 ids 参数，pytest 无法生成测试 ID。",
  "versions": [
    {
      "version": "7.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "如果 ids 是整数列表，强制转换可能丢失有意义的信息，且 pytest 期望字符串或可调用。",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "移除 ids 后测试仍会运行，但失去可读性，且可能影响测试报告。",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 1.0,
      "how": "在 parametrize 中提供字符串列表：`@pytest.mark.parametrize('arg', [1,2], ids=['one', 'two'])`",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "`@pytest.mark.parametrize('arg', [1,2], ids=lambda x: f'arg_{x}')`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}