{
  "id": "python/pytest-return-not-none",
  "signature": "PytestReturnNotNoneWarning: Expected None, but tests/test_x.py::test_foo returned 1, which will be an error in a future version of pytest",
  "signature_zh": "PytestReturnNotNoneWarning: 期望返回 None，但 tests/test_x.py::test_foo 返回了 1，这将在未来版本的 pytest 中成为错误",
  "regex": "PytestReturnNotNoneWarning:\\ Expected\\ None,\\ but\\ tests/test_x\\.py::test_foo\\ returned\\ 1,\\ which\\ will\\ be\\ an\\ error\\ in\\ a\\ future\\ version\\ of\\ pytest",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "A test function returns a value instead of using assert. Common when porting unittest-style tests or when a helper returns a truthy value that was intended as an assertion.",
  "root_cause_type": "generic",
  "root_cause_zh": "测试函数返回值而非使用 assert。常见于移植 unittest 风格测试，或辅助函数返回了本意作为断言的真值。",
  "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": "Silences the warning but the test may pass even when the intended condition is false, because no assertion occurs.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hides a real bug: the test is not actually asserting anything.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.98,
      "how": "# before\ndef test_foo():\n    return compute() == 1\n\n# after\ndef test_foo():\n    assert compute() == 1",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "[tool.pytest.ini_options]\nfilterwarnings = [\"error::pytest.PytestReturnNotNoneWarning\"]",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}