We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Start shipping our own type stubs
Typeshed houses very rudimentary type stubs for urllib3 but they're hidden within `requests.packages.urllib3` so Mypy can't take advantage of them when using urllib3 on its own. We could also probably improve on what is already in typeshed by adding better types than `Any` everywhere.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `noxfile.py`
Content:
```
1 import os
2 import shutil
3 import subprocess
4 
5 import nox
6 
7 # Whenever type-hints are completed on a file it should be added here so that
8 # this file will continue to be checked by mypy. Errors from other files are
9 # ignored.
10 TYPED_FILES = {
11     "src/urllib3/contrib/__init__.py",
12     "src/urllib3/contrib/_securetransport/bindings.py",
13     "src/urllib3/contrib/_securetransport/low_level.py",
14     "src/urllib3/contrib/ntlmpool.py",
15     "src/urllib3/contrib/pyopenssl.py",
16     "src/urllib3/contrib/securetransport.py",
17     "src/urllib3/contrib/socks.py",
18     "src/urllib3/__init__.py",
19     "src/urllib3/connection.py",
20     "src/urllib3/connectionpool.py",
21     "src/urllib3/exceptions.py",
22     "src/urllib3/_collections.py",
23     "src/urllib3/fields.py",
24     "src/urllib3/filepost.py",
25     "src/urllib3/poolmanager.py",
26     "src/urllib3/request.py",
27     "src/urllib3/response.py",
28     "src/urllib3/util/connection.py",
29     "src/urllib3/util/proxy.py",
30     "src/urllib3/util/queue.py",
31     "src/urllib3/util/response.py",
32     "src/urllib3/util/ssl_.py",
33     "src/urllib3/util/ssl_match_hostname.py",
34     "src/urllib3/util/ssltransport.py",
35     "src/urllib3/util/url.py",
36     "src/urllib3/util/request.py",
37     "src/urllib3/util/retry.py",
38     "src/urllib3/util/timeout.py",
39     "src/urllib3/util/util.py",
40     "src/urllib3/util/wait.py",
41 }
42 SOURCE_FILES = [
43     "docs/",
44     "dummyserver/",
45     "src/",
46     "test/",
47     "noxfile.py",
48     "setup.py",
49 ]
50 
51 
52 def tests_impl(session, extras="socks,secure,brotli"):
53     # Install deps and the package itself.
54     session.install("-r", "dev-requirements.txt")
55     session.install(f".[{extras}]")
56 
57     # Show the pip version.
58     session.run("pip", "--version")
59     # Print the Python version and bytesize.
60     session.run("python", "--version")
61     session.run("python", "-c", "import struct; print(struct.calcsize('P') * 8)")
62     # Print OpenSSL information.
63     session.run("python", "-m", "OpenSSL.debug")
64 
65     # Inspired from https://github.com/pyca/cryptography
66     # We use parallel mode and then combine here so that coverage.py will take
67     # the paths like .tox/pyXY/lib/pythonX.Y/site-packages/urllib3/__init__.py
68     # and collapse them into src/urllib3/__init__.py.
69 
70     session.run(
71         "coverage",
72         "run",
73         "--parallel-mode",
74         "-m",
75         "pytest",
76         "-r",
77         "a",
78         "--tb=native",
79         "--no-success-flaky-report",
80         *(session.posargs or ("test/",)),
81         env={"PYTHONWARNINGS": "always::DeprecationWarning"},
82     )
83     session.run("coverage", "combine")
84     session.run("coverage", "report", "-m")
85     session.run("coverage", "xml")
86 
87 
88 @nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10", "pypy"])
89 def test(session):
90     tests_impl(session)
91 
92 
93 @nox.session(python=["2.7"])
94 def unsupported_python2(session):
95     # Can't check both returncode and output with session.run
96     process = subprocess.run(
97         ["python", "setup.py", "install"],
98         env={**session.env},
99         text=True,
100         capture_output=True,
101     )
102     assert process.returncode == 1
103     print(process.stderr)
104     assert "Unsupported Python version" in process.stderr
105 
106 
107 @nox.session(python=["3"])
108 def test_brotlipy(session):
109     """Check that if 'brotlipy' is installed instead of 'brotli' or
110     'brotlicffi' that we still don't blow up.
111     """
112     session.install("brotlipy")
113     tests_impl(session, extras="socks,secure")
114 
115 
116 @nox.session()
117 def format(session):
118     """Run code formatters."""
119     session.install("pre-commit")
120     session.run("pre-commit", "--version")
121 
122     process = subprocess.run(
123         ["pre-commit", "run", "--all-files"],
124         env=session.env,
125         text=True,
126         stdout=subprocess.PIPE,
127         stderr=subprocess.STDOUT,
128     )
129     # Ensure that pre-commit itself ran successfully
130     assert process.returncode in (0, 1)
131 
132     lint(session)
133 
134 
135 @nox.session
136 def lint(session):
137     session.install("pre-commit")
138     session.run("pre-commit", "run", "--all-files")
139 
140     mypy(session)
141 
142 
143 @nox.session()
144 def mypy(session):
145     """Run mypy."""
146     session.install("mypy==0.812")
147     session.install("idna>=2.0.0")
148     session.run("mypy", "--version")
149 
150     session.log("mypy --strict src/urllib3")
151     all_errors, errors = [], []
152     process = subprocess.run(
153         ["mypy", "--strict", "src/urllib3"],
154         env=session.env,
155         text=True,
156         stdout=subprocess.PIPE,
157         stderr=subprocess.STDOUT,
158     )
159     # Ensure that mypy itself ran successfully
160     assert process.returncode in (0, 1)
161 
162     for line in process.stdout.split("\n"):
163         all_errors.append(line)
164         filepath = line.partition(":")[0]
165         if filepath.replace(".pyi", ".py") in TYPED_FILES:
166             errors.append(line)
167     session.log(f"all errors count: {len(all_errors)}")
168     if errors:
169         session.error("\n" + "\n".join(sorted(set(errors))))
170 
171 
172 @nox.session
173 def docs(session):
174     session.install("-r", "docs/requirements.txt")
175     session.install(".[socks,secure,brotli]")
176 
177     session.chdir("docs")
178     if os.path.exists("_build"):
179         shutil.rmtree("_build")
180     session.run("sphinx-build", "-b", "html", "-W", ".", "_build/html")
181
```
--- 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()

```

diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -4,41 +4,6 @@
 
 import nox
 
-# Whenever type-hints are completed on a file it should be added here so that
-# this file will continue to be checked by mypy. Errors from other files are
-# ignored.
-TYPED_FILES = {
-    "src/urllib3/contrib/__init__.py",
-    "src/urllib3/contrib/_securetransport/bindings.py",
-    "src/urllib3/contrib/_securetransport/low_level.py",
-    "src/urllib3/contrib/ntlmpool.py",
-    "src/urllib3/contrib/pyopenssl.py",
-    "src/urllib3/contrib/securetransport.py",
-    "src/urllib3/contrib/socks.py",
-    "src/urllib3/__init__.py",
-    "src/urllib3/connection.py",
-    "src/urllib3/connectionpool.py",
-    "src/urllib3/exceptions.py",
-    "src/urllib3/_collections.py",
-    "src/urllib3/fields.py",
-    "src/urllib3/filepost.py",
-    "src/urllib3/poolmanager.py",
-    "src/urllib3/request.py",
-    "src/urllib3/response.py",
-    "src/urllib3/util/connection.py",
-    "src/urllib3/util/proxy.py",
-    "src/urllib3/util/queue.py",
-    "src/urllib3/util/response.py",
-    "src/urllib3/util/ssl_.py",
-    "src/urllib3/util/ssl_match_hostname.py",
-    "src/urllib3/util/ssltransport.py",
-    "src/urllib3/util/url.py",
-    "src/urllib3/util/request.py",
-    "src/urllib3/util/retry.py",
-    "src/urllib3/util/timeout.py",
-    "src/urllib3/util/util.py",
-    "src/urllib3/util/wait.py",
-}
 SOURCE_FILES = [
     "docs/",
     "dummyserver/",
@@ -146,27 +111,7 @@
     session.install("mypy==0.812")
     session.install("idna>=2.0.0")
     session.run("mypy", "--version")
-
-    session.log("mypy --strict src/urllib3")
-    all_errors, errors = [], []
-    process = subprocess.run(
-        ["mypy", "--strict", "src/urllib3"],
-        env=session.env,
-        text=True,
-        stdout=subprocess.PIPE,
-        stderr=subprocess.STDOUT,
-    )
-    # Ensure that mypy itself ran successfully
-    assert process.returncode in (0, 1)
-
-    for line in process.stdout.split("\n"):
-        all_errors.append(line)
-        filepath = line.partition(":")[0]
-        if filepath.replace(".pyi", ".py") in TYPED_FILES:
-            errors.append(line)
-    session.log(f"all errors count: {len(all_errors)}")
-    if errors:
-        session.error("\n" + "\n".join(sorted(set(errors))))
+    session.run("mypy", "--strict", "src/urllib3")
 
 
 @nox.session

{"golden_diff": "diff --git a/noxfile.py b/noxfile.py\n--- a/noxfile.py\n+++ b/noxfile.py\n@@ -4,41 +4,6 @@\n \n import nox\n \n-# Whenever type-hints are completed on a file it should be added here so that\n-# this file will continue to be checked by mypy. Errors from other files are\n-# ignored.\n-TYPED_FILES = {\n-    \"src/urllib3/contrib/__init__.py\",\n-    \"src/urllib3/contrib/_securetransport/bindings.py\",\n-    \"src/urllib3/contrib/_securetransport/low_level.py\",\n-    \"src/urllib3/contrib/ntlmpool.py\",\n-    \"src/urllib3/contrib/pyopenssl.py\",\n-    \"src/urllib3/contrib/securetransport.py\",\n-    \"src/urllib3/contrib/socks.py\",\n-    \"src/urllib3/__init__.py\",\n-    \"src/urllib3/connection.py\",\n-    \"src/urllib3/connectionpool.py\",\n-    \"src/urllib3/exceptions.py\",\n-    \"src/urllib3/_collections.py\",\n-    \"src/urllib3/fields.py\",\n-    \"src/urllib3/filepost.py\",\n-    \"src/urllib3/poolmanager.py\",\n-    \"src/urllib3/request.py\",\n-    \"src/urllib3/response.py\",\n-    \"src/urllib3/util/connection.py\",\n-    \"src/urllib3/util/proxy.py\",\n-    \"src/urllib3/util/queue.py\",\n-    \"src/urllib3/util/response.py\",\n-    \"src/urllib3/util/ssl_.py\",\n-    \"src/urllib3/util/ssl_match_hostname.py\",\n-    \"src/urllib3/util/ssltransport.py\",\n-    \"src/urllib3/util/url.py\",\n-    \"src/urllib3/util/request.py\",\n-    \"src/urllib3/util/retry.py\",\n-    \"src/urllib3/util/timeout.py\",\n-    \"src/urllib3/util/util.py\",\n-    \"src/urllib3/util/wait.py\",\n-}\n SOURCE_FILES = [\n     \"docs/\",\n     \"dummyserver/\",\n@@ -146,27 +111,7 @@\n     session.install(\"mypy==0.812\")\n     session.install(\"idna>=2.0.0\")\n     session.run(\"mypy\", \"--version\")\n-\n-    session.log(\"mypy --strict src/urllib3\")\n-    all_errors, errors = [], []\n-    process = subprocess.run(\n-        [\"mypy\", \"--strict\", \"src/urllib3\"],\n-        env=session.env,\n-        text=True,\n-        stdout=subprocess.PIPE,\n-        stderr=subprocess.STDOUT,\n-    )\n-    # Ensure that mypy itself ran successfully\n-    assert process.returncode in (0, 1)\n-\n-    for line in process.stdout.split(\"\\n\"):\n-        all_errors.append(line)\n-        filepath = line.partition(\":\")[0]\n-        if filepath.replace(\".pyi\", \".py\") in TYPED_FILES:\n-            errors.append(line)\n-    session.log(f\"all errors count: {len(all_errors)}\")\n-    if errors:\n-        session.error(\"\\n\" + \"\\n\".join(sorted(set(errors))))\n+    session.run(\"mypy\", \"--strict\", \"src/urllib3\")\n \n \n @nox.session\n", "issue": "Start shipping our own type stubs\nTypeshed houses very rudimentary type stubs for urllib3 but they're hidden within `requests.packages.urllib3` so Mypy can't take advantage of them when using urllib3 on its own. We could also probably improve on what is already in typeshed by adding better types than `Any` everywhere.\n", "before_files": [{"content": "import os\nimport shutil\nimport subprocess\n\nimport nox\n\n# Whenever type-hints are completed on a file it should be added here so that\n# this file will continue to be checked by mypy. Errors from other files are\n# ignored.\nTYPED_FILES = {\n    \"src/urllib3/contrib/__init__.py\",\n    \"src/urllib3/contrib/_securetransport/bindings.py\",\n    \"src/urllib3/contrib/_securetransport/low_level.py\",\n    \"src/urllib3/contrib/ntlmpool.py\",\n    \"src/urllib3/contrib/pyopenssl.py\",\n    \"src/urllib3/contrib/securetransport.py\",\n    \"src/urllib3/contrib/socks.py\",\n    \"src/urllib3/__init__.py\",\n    \"src/urllib3/connection.py\",\n    \"src/urllib3/connectionpool.py\",\n    \"src/urllib3/exceptions.py\",\n    \"src/urllib3/_collections.py\",\n    \"src/urllib3/fields.py\",\n    \"src/urllib3/filepost.py\",\n    \"src/urllib3/poolmanager.py\",\n    \"src/urllib3/request.py\",\n    \"src/urllib3/response.py\",\n    \"src/urllib3/util/connection.py\",\n    \"src/urllib3/util/proxy.py\",\n    \"src/urllib3/util/queue.py\",\n    \"src/urllib3/util/response.py\",\n    \"src/urllib3/util/ssl_.py\",\n    \"src/urllib3/util/ssl_match_hostname.py\",\n    \"src/urllib3/util/ssltransport.py\",\n    \"src/urllib3/util/url.py\",\n    \"src/urllib3/util/request.py\",\n    \"src/urllib3/util/retry.py\",\n    \"src/urllib3/util/timeout.py\",\n    \"src/urllib3/util/util.py\",\n    \"src/urllib3/util/wait.py\",\n}\nSOURCE_FILES = [\n    \"docs/\",\n    \"dummyserver/\",\n    \"src/\",\n    \"test/\",\n    \"noxfile.py\",\n    \"setup.py\",\n]\n\n\ndef tests_impl(session, extras=\"socks,secure,brotli\"):\n    # Install deps and the package itself.\n    session.install(\"-r\", \"dev-requirements.txt\")\n    session.install(f\".[{extras}]\")\n\n    # Show the pip version.\n    session.run(\"pip\", \"--version\")\n    # Print the Python version and bytesize.\n    session.run(\"python\", \"--version\")\n    session.run(\"python\", \"-c\", \"import struct; print(struct.calcsize('P') * 8)\")\n    # Print OpenSSL information.\n    session.run(\"python\", \"-m\", \"OpenSSL.debug\")\n\n    # Inspired from https://github.com/pyca/cryptography\n    # We use parallel mode and then combine here so that coverage.py will take\n    # the paths like .tox/pyXY/lib/pythonX.Y/site-packages/urllib3/__init__.py\n    # and collapse them into src/urllib3/__init__.py.\n\n    session.run(\n        \"coverage\",\n        \"run\",\n        \"--parallel-mode\",\n        \"-m\",\n        \"pytest\",\n        \"-r\",\n        \"a\",\n        \"--tb=native\",\n        \"--no-success-flaky-report\",\n        *(session.posargs or (\"test/\",)),\n        env={\"PYTHONWARNINGS\": \"always::DeprecationWarning\"},\n    )\n    session.run(\"coverage\", \"combine\")\n    session.run(\"coverage\", \"report\", \"-m\")\n    session.run(\"coverage\", \"xml\")\n\n\n@nox.session(python=[\"3.6\", \"3.7\", \"3.8\", \"3.9\", \"3.10\", \"pypy\"])\ndef test(session):\n    tests_impl(session)\n\n\n@nox.session(python=[\"2.7\"])\ndef unsupported_python2(session):\n    # Can't check both returncode and output with session.run\n    process = subprocess.run(\n        [\"python\", \"setup.py\", \"install\"],\n        env={**session.env},\n        text=True,\n        capture_output=True,\n    )\n    assert process.returncode == 1\n    print(process.stderr)\n    assert \"Unsupported Python version\" in process.stderr\n\n\n@nox.session(python=[\"3\"])\ndef test_brotlipy(session):\n    \"\"\"Check that if 'brotlipy' is installed instead of 'brotli' or\n    'brotlicffi' that we still don't blow up.\n    \"\"\"\n    session.install(\"brotlipy\")\n    tests_impl(session, extras=\"socks,secure\")\n\n\n@nox.session()\ndef format(session):\n    \"\"\"Run code formatters.\"\"\"\n    session.install(\"pre-commit\")\n    session.run(\"pre-commit\", \"--version\")\n\n    process = subprocess.run(\n        [\"pre-commit\", \"run\", \"--all-files\"],\n        env=session.env,\n        text=True,\n        stdout=subprocess.PIPE,\n        stderr=subprocess.STDOUT,\n    )\n    # Ensure that pre-commit itself ran successfully\n    assert process.returncode in (0, 1)\n\n    lint(session)\n\n\n@nox.session\ndef lint(session):\n    session.install(\"pre-commit\")\n    session.run(\"pre-commit\", \"run\", \"--all-files\")\n\n    mypy(session)\n\n\n@nox.session()\ndef mypy(session):\n    \"\"\"Run mypy.\"\"\"\n    session.install(\"mypy==0.812\")\n    session.install(\"idna>=2.0.0\")\n    session.run(\"mypy\", \"--version\")\n\n    session.log(\"mypy --strict src/urllib3\")\n    all_errors, errors = [], []\n    process = subprocess.run(\n        [\"mypy\", \"--strict\", \"src/urllib3\"],\n        env=session.env,\n        text=True,\n        stdout=subprocess.PIPE,\n        stderr=subprocess.STDOUT,\n    )\n    # Ensure that mypy itself ran successfully\n    assert process.returncode in (0, 1)\n\n    for line in process.stdout.split(\"\\n\"):\n        all_errors.append(line)\n        filepath = line.partition(\":\")[0]\n        if filepath.replace(\".pyi\", \".py\") in TYPED_FILES:\n            errors.append(line)\n    session.log(f\"all errors count: {len(all_errors)}\")\n    if errors:\n        session.error(\"\\n\" + \"\\n\".join(sorted(set(errors))))\n\n\n@nox.session\ndef docs(session):\n    session.install(\"-r\", \"docs/requirements.txt\")\n    session.install(\".[socks,secure,brotli]\")\n\n    session.chdir(\"docs\")\n    if os.path.exists(\"_build\"):\n        shutil.rmtree(\"_build\")\n    session.run(\"sphinx-build\", \"-b\", \"html\", \"-W\", \".\", \"_build/html\")\n", "path": "noxfile.py"}], "after_files": [{"content": "import os\nimport shutil\nimport subprocess\n\nimport nox\n\nSOURCE_FILES = [\n    \"docs/\",\n    \"dummyserver/\",\n    \"src/\",\n    \"test/\",\n    \"noxfile.py\",\n    \"setup.py\",\n]\n\n\ndef tests_impl(session, extras=\"socks,secure,brotli\"):\n    # Install deps and the package itself.\n    session.install(\"-r\", \"dev-requirements.txt\")\n    session.install(f\".[{extras}]\")\n\n    # Show the pip version.\n    session.run(\"pip\", \"--version\")\n    # Print the Python version and bytesize.\n    session.run(\"python\", \"--version\")\n    session.run(\"python\", \"-c\", \"import struct; print(struct.calcsize('P') * 8)\")\n    # Print OpenSSL information.\n    session.run(\"python\", \"-m\", \"OpenSSL.debug\")\n\n    # Inspired from https://github.com/pyca/cryptography\n    # We use parallel mode and then combine here so that coverage.py will take\n    # the paths like .tox/pyXY/lib/pythonX.Y/site-packages/urllib3/__init__.py\n    # and collapse them into src/urllib3/__init__.py.\n\n    session.run(\n        \"coverage\",\n        \"run\",\n        \"--parallel-mode\",\n        \"-m\",\n        \"pytest\",\n        \"-r\",\n        \"a\",\n        \"--tb=native\",\n        \"--no-success-flaky-report\",\n        *(session.posargs or (\"test/\",)),\n        env={\"PYTHONWARNINGS\": \"always::DeprecationWarning\"},\n    )\n    session.run(\"coverage\", \"combine\")\n    session.run(\"coverage\", \"report\", \"-m\")\n    session.run(\"coverage\", \"xml\")\n\n\n@nox.session(python=[\"3.6\", \"3.7\", \"3.8\", \"3.9\", \"3.10\", \"pypy\"])\ndef test(session):\n    tests_impl(session)\n\n\n@nox.session(python=[\"2.7\"])\ndef unsupported_python2(session):\n    # Can't check both returncode and output with session.run\n    process = subprocess.run(\n        [\"python\", \"setup.py\", \"install\"],\n        env={**session.env},\n        text=True,\n        capture_output=True,\n    )\n    assert process.returncode == 1\n    print(process.stderr)\n    assert \"Unsupported Python version\" in process.stderr\n\n\n@nox.session(python=[\"3\"])\ndef test_brotlipy(session):\n    \"\"\"Check that if 'brotlipy' is installed instead of 'brotli' or\n    'brotlicffi' that we still don't blow up.\n    \"\"\"\n    session.install(\"brotlipy\")\n    tests_impl(session, extras=\"socks,secure\")\n\n\n@nox.session()\ndef format(session):\n    \"\"\"Run code formatters.\"\"\"\n    session.install(\"pre-commit\")\n    session.run(\"pre-commit\", \"--version\")\n\n    process = subprocess.run(\n        [\"pre-commit\", \"run\", \"--all-files\"],\n        env=session.env,\n        text=True,\n        stdout=subprocess.PIPE,\n        stderr=subprocess.STDOUT,\n    )\n    # Ensure that pre-commit itself ran successfully\n    assert process.returncode in (0, 1)\n\n    lint(session)\n\n\n@nox.session\ndef lint(session):\n    session.install(\"pre-commit\")\n    session.run(\"pre-commit\", \"run\", \"--all-files\")\n\n    mypy(session)\n\n\n@nox.session()\ndef mypy(session):\n    \"\"\"Run mypy.\"\"\"\n    session.install(\"mypy==0.812\")\n    session.install(\"idna>=2.0.0\")\n    session.run(\"mypy\", \"--version\")\n    session.run(\"mypy\", \"--strict\", \"src/urllib3\")\n\n\n@nox.session\ndef docs(session):\n    session.install(\"-r\", \"docs/requirements.txt\")\n    session.install(\".[socks,secure,brotli]\")\n\n    session.chdir(\"docs\")\n    if os.path.exists(\"_build\"):\n        shutil.rmtree(\"_build\")\n    session.run(\"sphinx-build\", \"-b\", \"html\", \"-W\", \".\", \"_build/html\")\n", "path": "noxfile.py"}]}