{
  "id": "python/pytest-parametrize-id-special-chars",
  "signature": "TypeError: '<' not supported between instances of 'int' and 'str'",
  "signature_zh": "TypeError: 不支持 '<' 在 'int' 和 'str' 实例之间进行比较",
  "regex": "TypeError:\\ '<'\\ not\\ supported\\ between\\ instances\\ of\\ 'int'\\ and\\ 'str'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Passing mixed types as `ids=` to `@pytest.mark.parametrize` (e.g. ids=[1, 'two']) causes pytest to sort them for display, which fails when comparing int and str.",
  "root_cause_type": "generic",
  "root_cause_zh": "向 `@pytest.mark.parametrize` 的 `ids=` 传入混合类型（如 ids=[1, 'two']）会使 pytest 在显示时排序它们，比较 int 与 str 时失败。",
  "versions": [
    {
      "version": "7.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Works, but loses readability; long parameter values produce unreadable test IDs.",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Sorting mixed types raises the same TypeError before pytest even sees it.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Cast all ids to strings:\n\n@pytest.mark.parametrize('n', [1, 2, 3], ids=lambda n: f'case-{n}')",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Provide a callable for ids that returns unique strings:\n\nids=lambda v: str(v).replace(' ', '_')",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}