prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  release.py should link to GH create PAT page
  We can pre-fill what permissions are needed to improve the UX of doing a release. Example URL: https://github.com/settings/tokens/new?description=foo&scopes=repo,workflow
  
  @reaperhulk do you know what scopes are required?
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `release.py`
  Content:
  ```
  1 # This file is dual licensed under the terms of the Apache License, Version
  2 # 2.0, and the BSD License. See the LICENSE file in the root of this repository
  3 # for complete details.
  4 
  5 import getpass
  6 import glob
  7 import io
  8 import os
  9 import subprocess
  10 import time
  11 import zipfile
  12 
  13 import click
  14 
  15 import requests
  16 
  17 
  18 def run(*args, **kwargs):
  19     print("[running] {0}".format(list(args)))
  20     subprocess.check_call(list(args), **kwargs)
  21 
  22 
  23 def wait_for_build_complete_github_actions(session, token, run_url):
  24     while True:
  25         response = session.get(
  26             run_url,
  27             headers={
  28                 "Content-Type": "application/json",
  29                 "Authorization": "token {}".format(token),
  30             },
  31         )
  32         response.raise_for_status()
  33         if response.json()["conclusion"] is not None:
  34             break
  35         time.sleep(3)
  36 
  37 
  38 def download_artifacts_github_actions(session, token, run_url):
  39     response = session.get(
  40         run_url,
  41         headers={
  42             "Content-Type": "application/json",
  43             "Authorization": "token {}".format(token),
  44         },
  45     )
  46     response.raise_for_status()
  47 
  48     response = session.get(
  49         response.json()["artifacts_url"],
  50         headers={
  51             "Content-Type": "application/json",
  52             "Authorization": "token {}".format(token),
  53         },
  54     )
  55     response.raise_for_status()
  56     paths = []
  57     for artifact in response.json()["artifacts"]:
  58         response = session.get(
  59             artifact["archive_download_url"],
  60             headers={
  61                 "Content-Type": "application/json",
  62                 "Authorization": "token {}".format(token),
  63             },
  64         )
  65         with zipfile.ZipFile(io.BytesIO(response.content)) as z:
  66             for name in z.namelist():
  67                 if not name.endswith(".whl"):
  68                     continue
  69                 p = z.open(name)
  70                 out_path = os.path.join(
  71                     os.path.dirname(__file__),
  72                     "dist",
  73                     os.path.basename(name),
  74                 )
  75                 with open(out_path, "wb") as f:
  76                     f.write(p.read())
  77                 paths.append(out_path)
  78     return paths
  79 
  80 
  81 def fetch_github_actions_wheels(token, version):
  82     session = requests.Session()
  83 
  84     response = session.get(
  85         (
  86             "https://api.github.com/repos/pyca/cryptography/actions/workflows/"
  87             "wheel-builder.yml/runs?event=push"
  88         ),
  89         headers={
  90             "Content-Type": "application/json",
  91             "Authorization": "token {}".format(token),
  92         },
  93     )
  94     response.raise_for_status()
  95     run_url = response.json()["workflow_runs"][0]["url"]
  96     wait_for_build_complete_github_actions(session, token, run_url)
  97     return download_artifacts_github_actions(session, token, run_url)
  98 
  99 
  100 @click.command()
  101 @click.argument("version")
  102 def release(version):
  103     """
  104     ``version`` should be a string like '0.4' or '1.0'.
  105     """
  106     github_token = getpass.getpass("Github person access token: ")
  107 
  108     # Tag and push the tag (this will trigger the wheel builder in Actions)
  109     run("git", "tag", "-s", version, "-m", "{0} release".format(version))
  110     run("git", "push", "--tags")
  111 
  112     # Generate and upload vector packages
  113     run("python", "setup.py", "sdist", "bdist_wheel", cwd="vectors/")
  114     packages = glob.glob(
  115         "vectors/dist/cryptography_vectors-{0}*".format(version)
  116     )
  117     run("twine", "upload", "-s", *packages)
  118 
  119     # Generate sdist for upload
  120     run("python", "setup.py", "sdist")
  121     sdist = glob.glob("dist/cryptography-{0}*".format(version))
  122 
  123     # Wait for Actions to complete and download the wheels
  124     github_actions_wheel_paths = fetch_github_actions_wheels(
  125         github_token, version
  126     )
  127 
  128     # Upload sdist and wheels
  129     run("twine", "upload", "-s", *sdist)
  130     run("twine", "upload", *github_actions_wheel_paths)
  131 
  132 
  133 if __name__ == "__main__":
  134     release()
  135
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/release.py b/release.py
  --- a/release.py
  +++ b/release.py
  @@ -103,6 +103,11 @@
       """
       ``version`` should be a string like '0.4' or '1.0'.
       """
  +    print(
  +        f"Create a new GH PAT at: "
  +        f"https://github.com/settings/tokens/new?"
  +        f"description={version}&scopes=repo"
  +    )
       github_token = getpass.getpass("Github person access token: ")
   
       # Tag and push the tag (this will trigger the wheel builder in Actions)
  
verification_info: {"golden_diff": "diff --git a/release.py b/release.py\n--- a/release.py\n+++ b/release.py\n@@ -103,6 +103,11 @@\n     \"\"\"\n     ``version`` should be a string like '0.4' or '1.0'.\n     \"\"\"\n+    print(\n+        f\"Create a new GH PAT at: \"\n+        f\"https://github.com/settings/tokens/new?\"\n+        f\"description={version}&scopes=repo\"\n+    )\n     github_token = getpass.getpass(\"Github person access token: \")\n \n     # Tag and push the tag (this will trigger the wheel builder in Actions)\n", "issue": "release.py should link to GH create PAT page\nWe can pre-fill what permissions are needed to improve the UX of doing a release. Example URL: https://github.com/settings/tokens/new?description=foo&scopes=repo,workflow\r\n\r\n@reaperhulk do you know what scopes are required?\n", "before_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nimport getpass\nimport glob\nimport io\nimport os\nimport subprocess\nimport time\nimport zipfile\n\nimport click\n\nimport requests\n\n\ndef run(*args, **kwargs):\n    print(\"[running] {0}\".format(list(args)))\n    subprocess.check_call(list(args), **kwargs)\n\n\ndef wait_for_build_complete_github_actions(session, token, run_url):\n    while True:\n        response = session.get(\n            run_url,\n            headers={\n                \"Content-Type\": \"application/json\",\n                \"Authorization\": \"token {}\".format(token),\n            },\n        )\n        response.raise_for_status()\n        if response.json()[\"conclusion\"] is not None:\n            break\n        time.sleep(3)\n\n\ndef download_artifacts_github_actions(session, token, run_url):\n    response = session.get(\n        run_url,\n        headers={\n            \"Content-Type\": \"application/json\",\n            \"Authorization\": \"token {}\".format(token),\n        },\n    )\n    response.raise_for_status()\n\n    response = session.get(\n        response.json()[\"artifacts_url\"],\n        headers={\n            \"Content-Type\": \"application/json\",\n            \"Authorization\": \"token {}\".format(token),\n        },\n    )\n    response.raise_for_status()\n    paths = []\n    for artifact in response.json()[\"artifacts\"]:\n        response = session.get(\n            artifact[\"archive_download_url\"],\n            headers={\n                \"Content-Type\": \"application/json\",\n                \"Authorization\": \"token {}\".format(token),\n            },\n        )\n        with zipfile.ZipFile(io.BytesIO(response.content)) as z:\n            for name in z.namelist():\n                if not name.endswith(\".whl\"):\n                    continue\n                p = z.open(name)\n                out_path = os.path.join(\n                    os.path.dirname(__file__),\n                    \"dist\",\n                    os.path.basename(name),\n                )\n                with open(out_path, \"wb\") as f:\n                    f.write(p.read())\n                paths.append(out_path)\n    return paths\n\n\ndef fetch_github_actions_wheels(token, version):\n    session = requests.Session()\n\n    response = session.get(\n        (\n            \"https://api.github.com/repos/pyca/cryptography/actions/workflows/\"\n            \"wheel-builder.yml/runs?event=push\"\n        ),\n        headers={\n            \"Content-Type\": \"application/json\",\n            \"Authorization\": \"token {}\".format(token),\n        },\n    )\n    response.raise_for_status()\n    run_url = response.json()[\"workflow_runs\"][0][\"url\"]\n    wait_for_build_complete_github_actions(session, token, run_url)\n    return download_artifacts_github_actions(session, token, run_url)\n\n\n@click.command()\n@click.argument(\"version\")\ndef release(version):\n    \"\"\"\n    ``version`` should be a string like '0.4' or '1.0'.\n    \"\"\"\n    github_token = getpass.getpass(\"Github person access token: \")\n\n    # Tag and push the tag (this will trigger the wheel builder in Actions)\n    run(\"git\", \"tag\", \"-s\", version, \"-m\", \"{0} release\".format(version))\n    run(\"git\", \"push\", \"--tags\")\n\n    # Generate and upload vector packages\n    run(\"python\", \"setup.py\", \"sdist\", \"bdist_wheel\", cwd=\"vectors/\")\n    packages = glob.glob(\n        \"vectors/dist/cryptography_vectors-{0}*\".format(version)\n    )\n    run(\"twine\", \"upload\", \"-s\", *packages)\n\n    # Generate sdist for upload\n    run(\"python\", \"setup.py\", \"sdist\")\n    sdist = glob.glob(\"dist/cryptography-{0}*\".format(version))\n\n    # Wait for Actions to complete and download the wheels\n    github_actions_wheel_paths = fetch_github_actions_wheels(\n        github_token, version\n    )\n\n    # Upload sdist and wheels\n    run(\"twine\", \"upload\", \"-s\", *sdist)\n    run(\"twine\", \"upload\", *github_actions_wheel_paths)\n\n\nif __name__ == \"__main__\":\n    release()\n", "path": "release.py"}], "after_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nimport getpass\nimport glob\nimport io\nimport os\nimport subprocess\nimport time\nimport zipfile\n\nimport click\n\nimport requests\n\n\ndef run(*args, **kwargs):\n    print(\"[running] {0}\".format(list(args)))\n    subprocess.check_call(list(args), **kwargs)\n\n\ndef wait_for_build_complete_github_actions(session, token, run_url):\n    while True:\n        response = session.get(\n            run_url,\n            headers={\n                \"Content-Type\": \"application/json\",\n                \"Authorization\": \"token {}\".format(token),\n            },\n        )\n        response.raise_for_status()\n        if response.json()[\"conclusion\"] is not None:\n            break\n        time.sleep(3)\n\n\ndef download_artifacts_github_actions(session, token, run_url):\n    response = session.get(\n        run_url,\n        headers={\n            \"Content-Type\": \"application/json\",\n            \"Authorization\": \"token {}\".format(token),\n        },\n    )\n    response.raise_for_status()\n\n    response = session.get(\n        response.json()[\"artifacts_url\"],\n        headers={\n            \"Content-Type\": \"application/json\",\n            \"Authorization\": \"token {}\".format(token),\n        },\n    )\n    response.raise_for_status()\n    paths = []\n    for artifact in response.json()[\"artifacts\"]:\n        response = session.get(\n            artifact[\"archive_download_url\"],\n            headers={\n                \"Content-Type\": \"application/json\",\n                \"Authorization\": \"token {}\".format(token),\n            },\n        )\n        with zipfile.ZipFile(io.BytesIO(response.content)) as z:\n            for name in z.namelist():\n                if not name.endswith(\".whl\"):\n                    continue\n                p = z.open(name)\n                out_path = os.path.join(\n                    os.path.dirname(__file__),\n                    \"dist\",\n                    os.path.basename(name),\n                )\n                with open(out_path, \"wb\") as f:\n                    f.write(p.read())\n                paths.append(out_path)\n    return paths\n\n\ndef fetch_github_actions_wheels(token, version):\n    session = requests.Session()\n\n    response = session.get(\n        (\n            \"https://api.github.com/repos/pyca/cryptography/actions/workflows/\"\n            \"wheel-builder.yml/runs?event=push\"\n        ),\n        headers={\n            \"Content-Type\": \"application/json\",\n            \"Authorization\": \"token {}\".format(token),\n        },\n    )\n    response.raise_for_status()\n    run_url = response.json()[\"workflow_runs\"][0][\"url\"]\n    wait_for_build_complete_github_actions(session, token, run_url)\n    return download_artifacts_github_actions(session, token, run_url)\n\n\n@click.command()\n@click.argument(\"version\")\ndef release(version):\n    \"\"\"\n    ``version`` should be a string like '0.4' or '1.0'.\n    \"\"\"\n    print(\n        f\"Create a new GH PAT at: \"\n        f\"https://github.com/settings/tokens/new?\"\n        f\"description={version}&scopes=repo\"\n    )\n    github_token = getpass.getpass(\"Github person access token: \")\n\n    # Tag and push the tag (this will trigger the wheel builder in Actions)\n    run(\"git\", \"tag\", \"-s\", version, \"-m\", \"{0} release\".format(version))\n    run(\"git\", \"push\", \"--tags\")\n\n    # Generate and upload vector packages\n    run(\"python\", \"setup.py\", \"sdist\", \"bdist_wheel\", cwd=\"vectors/\")\n    packages = glob.glob(\n        \"vectors/dist/cryptography_vectors-{0}*\".format(version)\n    )\n    run(\"twine\", \"upload\", \"-s\", *packages)\n\n    # Generate sdist for upload\n    run(\"python\", \"setup.py\", \"sdist\")\n    sdist = glob.glob(\"dist/cryptography-{0}*\".format(version))\n\n    # Wait for Actions to complete and download the wheels\n    github_actions_wheel_paths = fetch_github_actions_wheels(\n        github_token, version\n    )\n\n    # Upload sdist and wheels\n    run(\"twine\", \"upload\", \"-s\", *sdist)\n    run(\"twine\", \"upload\", *github_actions_wheel_paths)\n\n\nif __name__ == \"__main__\":\n    release()\n", "path": "release.py"}]}