{
  "id": "python/asyncio-await-outside-async",
  "signature": "SyntaxError: 'await' outside async function",
  "signature_zh": "SyntaxError: 'await' 在 async 函数之外",
  "regex": "SyntaxError:\\ 'await'\\ outside\\ async\\ function",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Using await at module level or inside a non-async def; await is only valid inside async def (or top-level in a notebook/repl with special support).",
  "root_cause_type": "generic",
  "root_cause_zh": "在模块级别或非 async def 内使用 await；await 仅在 async def 内有效（或 notebook/repl 中顶层特殊支持）。",
  "versions": [
    {
      "version": "3.5+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This is a parser-level SyntaxError, not a type error; comments cannot suppress it.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "SyntaxError occurs at compile time before any except block is entered.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.97,
      "how": "import asyncio\n\nasync def main():\n    await some_coro()\n\nasyncio.run(main())",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.93,
      "how": "import asyncio\nresult = asyncio.run(some_coro())",
      "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-01-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}