internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: urllib3/urllib3

Issue:
Collect mypy requirements in their own file
We currently install mypy dependencies one by one:

https://github.com/urllib3/urllib3/blob/0a4839af7103e9ad71d26bf5ba7914e765577efe/noxfile.py#L162-L169

It was fine initially, but we currently install 8 dependencies that way. That's slower than necessary and isn't a format tools like dependabot can understand.

Instead, put those dependencies in a file called `mypy-requirements.txt` and install them just like we install dev-requirements.txt:

https://github.com/urllib3/urllib3/blob/0a4839af7103e9ad71d26bf5ba7914e765577efe/noxfile.py#L23


Discussion:

Resolving patch:
diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -159,14 +159,7 @@ def lint(session: nox.Session) -> None:
 @nox.session(python="3.8")
 def mypy(session: nox.Session) -> None:
     """Run mypy."""
-    session.install("mypy==0.910")
-    session.install("idna>=2.0.0")
-    session.install("cryptography>=1.3.4")
-    session.install("tornado>=6.1")
-    session.install("pytest>=6.2")
-    session.install("trustme==0.9.0")
-    session.install("types-python-dateutil")
-    session.install("nox")
+    session.install("-r", "mypy-requirements.txt")
     session.run("mypy", "--version")
     session.run(
         "mypy",


Test patch:
Repository: urllib3/urllib3

Issue:
Remove integration tests for Botocore with Python 2.7
Botocore dropped support for Python 2.7 in July so we don't have to do integration testing with Botocore+Python 2.7 on the 1.26.x branch any longer.

Reference: https://github.com/urllib3/urllib3/pull/2422


Discussion:
I will work on this. 

Resolving patch:
diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -88,7 +88,7 @@ def git_clone(session, git_url):
     session.run("git", "clone", "--depth", "1", git_url, external=True)
 
 
-@nox.session(python=["2.7", "3.9"])
+@nox.session(python=["3.9"])
 def downstream_botocore(session):
     root = os.getcwd()
     tmp_dir = session.create_tmp()


Test patch:
Repository: urllib3/urllib3

Issue:
Test development versions of Python
Uses the `3.11-dev` and `nightly` deadsnakes release streams to test urllib3 against Python versions.


Discussion:

Resolving patch:
diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -57,7 +57,7 @@ def tests_impl(
     session.run("coverage", "xml")
 
 
-@nox.session(python=["3.7", "3.8", "3.9", "3.10", "pypy"])
+@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "pypy"])
 def test(session: nox.Session) -> None:
     tests_impl(session)
 


Test patch:
Repository: urllib3/urllib3

Issue:
Problem with urllib3.HTTPResponse.geturl() type hint
### Subject

Why the return type hint for `urllib3.response.BaseHTTPResponse.geturl()` is `Optional[Union[str, "Literal[False]"]]` but not `Optional[str]` ?



Discussion:

Resolving patch:
diff --git a/src/urllib3/response.py b/src/urllib3/response.py
--- a/src/urllib3/response.py
+++ b/src/urllib3/response.py
@@ -411,7 +411,7 @@ def getheader(self, name: str, default: Optional[str] = None) -> Optional[str]:
     def info(self) -> HTTPHeaderDict:
         return self.headers
 
-    def geturl(self) -> Optional[Union[str, "Literal[False]"]]:
+    def geturl(self) -> Optional[str]:
         return self.url
 
 


Test patch:
Repository: urllib3/urllib3

Issue:
`format` session fail to run locally on Window platform
### Subject
When I ran `nox -rs format` to format the files,  the format process terminates due to `FileNotFoundError` reported at line 139 at file `noxfile.py`:

![image](https://user-images.githubusercontent.com/23013350/184066564-3a322445-c7b8-48ba-8ee9-4e747e964037.png)


### Environment
Window 10

### Steps to Reproduce
Just ran `nox -rs format` on Window machine.


I suspect the created `process` could not find the files properly, and my workaround is to using `session.run()` instead:
```python
@nox.session()
def format(session: nox.Session) -> None:
    """Run code formatters."""
    session.install("pre-commit")
    session.run("pre-commit", "--version")

    # process = subprocess.run(
    #     ["pre-commit", "run", "--all-files"],
    #     env=session.env,
    #     text=True,
    #     stdout=subprocess.PIPE,
    #     stderr=subprocess.STDOUT,
    # )
    # # Ensure that pre-commit itself ran successfully
    # assert process.returncode in (0, 1)

    session.run("pre-commit", "run", "--all-files") # my workaround

    lint(session)
```

Perhaps this failure is due to my improper environment setup for the repo. If so, please correct me.

Thanks.


Discussion:
Nice catch! Actually we can completely remove the call to `pre-commit run --all-files` in `format()`, since `lint()` calls it already. Can you please open a pull request to do that?
@pquentin 
Ya, It seems the `lint()` calls it already. I can create the PR for that.  

Before this, my another question is: For here what's the difference between `format()` and `lint()`?  From the code, they seems doing the same thing. Can we completely remove  `format()` function from the file  or we might add on something in this function in the future?

Resolving patch:
diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -133,19 +133,6 @@ def downstream_requests(session: nox.Session) -> None:
 @nox.session()
 def format(session: nox.Session) -> None:
     """Run code formatters."""
-    session.install("pre-commit")
-    session.run("pre-commit", "--version")
-
-    process = subprocess.run(
-        ["pre-commit", "run", "--all-files"],
-        env=session.env,
-        text=True,
-        stdout=subprocess.PIPE,
-        stderr=subprocess.STDOUT,
-    )
-    # Ensure that pre-commit itself ran successfully
-    assert process.returncode in (0, 1)
-
     lint(session)
 
 


Test patch:
Repository: urllib3/urllib3

Issue:
Write a Migration Guide for v1.26.x -> v2.0.0
Can be a part of the v2.0.0 Roadmap documentation. Would be good to detail the specific steps and causes of all DeprecationWarnings and be URL-linkable so we can point to these docs within the actual warnings.


Discussion:
This doesn't seem realistic right now, going to close this one until we can get volunteers.
I do think we need something like that, but it can live in the breaking section of the changelog
Always read issue titles closely before closing. Thought this was the docs translation issue.
Useful migration guides that can be used for inspiration:
 * https://www.elastic.co/guide/en/elasticsearch/client/python-api/master/migration.html
 * https://esrally.readthedocs.io/en/stable/migrate.html

Resolving patch:
diff --git a/src/urllib3/_version.py b/src/urllib3/_version.py
--- a/src/urllib3/_version.py
+++ b/src/urllib3/_version.py
@@ -1,2 +1,2 @@
 # This file is protected via CODEOWNERS
-__version__ = "2.0.0.dev0"
+__version__ = "2.0.0a1"
diff --git a/src/urllib3/poolmanager.py b/src/urllib3/poolmanager.py
--- a/src/urllib3/poolmanager.py
+++ b/src/urllib3/poolmanager.py
@@ -324,7 +324,7 @@ def connection_from_context(
         if "strict" in request_context:
             warnings.warn(
                 "The 'strict' parameter is no longer needed on Python 3+. "
-                "This will raise an error in urllib3 v3.0.0.",
+                "This will raise an error in urllib3 v2.1.0.",
                 DeprecationWarning,
             )
             request_context.pop("strict")


Test patch:
diff --git a/test/test_poolmanager.py b/test/test_poolmanager.py
--- a/test/test_poolmanager.py
+++ b/test/test_poolmanager.py
@@ -274,7 +274,7 @@ def test_connection_from_context_strict_param(
 
         msg = (
             "The 'strict' parameter is no longer needed on Python 3+. "
-            "This will raise an error in urllib3 v3.0.0."
+            "This will raise an error in urllib3 v2.1.0."
         )
         record = records[0]
         assert isinstance(record.message, Warning)
Repository: urllib3/urllib3

Issue:
Make our downstream integration tests re-runnable
Currently our downstream tests both clone a git repository into the venv created by nox. Due to how the setup is written the nox session will fail when run a second time due to the repository already existing. It would be nice to be able to run:

`$ nox -rs downstream_requests` over and over without needing to reclone the repository or manually configure the test setup.

I think checking that the repository exists and if so not applying the git patches and continuing as normal would work okay for this case?


Discussion:

Resolving patch:
diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -89,7 +89,21 @@ def test_brotlipy(session: nox.Session) -> None:
 
 
 def git_clone(session: nox.Session, git_url: str) -> None:
-    session.run("git", "clone", "--depth", "1", git_url, external=True)
+    """We either clone the target repository or if already exist
+    simply reset the state and pull.
+    """
+    expected_directory = git_url.split("/")[-1]
+
+    if expected_directory.endswith(".git"):
+        expected_directory = expected_directory[:-4]
+
+    if not os.path.isdir(expected_directory):
+        session.run("git", "clone", "--depth", "1", git_url, external=True)
+    else:
+        session.run(
+            "git", "-C", expected_directory, "reset", "--hard", "HEAD", external=True
+        )
+        session.run("git", "-C", expected_directory, "pull", external=True)
 
 
 @nox.session()


Test patch:
Repository: urllib3/urllib3

Issue:
parse_url with :0 returns port=None
it should return port=0 instead


Discussion:
@venthur Would you mind backporting #2849 to 1.26.x too?
@pquentin I can take the backporting change.
Sure, please go ahead!

Resolving patch:
diff --git a/src/urllib3/util/url.py b/src/urllib3/util/url.py
--- a/src/urllib3/util/url.py
+++ b/src/urllib3/util/url.py
@@ -63,7 +63,7 @@
 BRACELESS_IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT[2:-2] + "$")
 ZONE_ID_RE = re.compile("(" + ZONE_ID_PAT + r")\]$")
 
-_HOST_PORT_PAT = ("^(%s|%s|%s)(?::0*([0-9]{0,5}))?$") % (
+_HOST_PORT_PAT = ("^(%s|%s|%s)(?::0*?(|0|[1-9][0-9]{0,4}))?$") % (
     REG_NAME_PAT,
     IPV4_PAT,
     IPV6_ADDRZ_PAT,


Test patch:
diff --git a/test/test_util.py b/test/test_util.py
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -351,6 +351,13 @@ def test_parse_url_remove_leading_zeros(self):
         url = parse_url("https://example.com:0000000000080")
         assert url.port == 80
 
+    def test_parse_url_only_zeros(self):
+        url = parse_url("https://example.com:0")
+        assert url.port == 0
+
+        url = parse_url("https://example.com:000000000000")
+        assert url.port == 0
+
     def test_Url_str(self):
         U = Url("http", host="google.com")
         assert str(U) == U.url
Repository: urllib3/urllib3

Issue:
Add OpenGraph information to our documentation
Would be good to fill in some open graph fields for our documentation so when we link to things they show up with rich output / images rather than as a standard link. Really works nicely for Social Media, Slack, etc.

More information: https://ogp.me/


Discussion:
@sethmlarson I'm working on it 👍🏻 

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -35,8 +35,16 @@
     "sphinx_copybutton",
     "sphinx.ext.doctest",
     "sphinx.ext.intersphinx",
+    "sphinxext.opengraph",
 ]
 
+# Open Graph metadata
+ogp_title = "urllib3 documentation"
+ogp_site_url = "https://urllib3.readthedocs.io"
+ogp_type = "website"
+ogp_image = "https://github.com/urllib3/urllib3/raw/main/docs/_static/banner_github.svg"
+ogp_description = "urllib3 is a user-friendly HTTP client library for Python."
+
 # Test code blocks only when explicitly specified
 doctest_test_doctest_blocks = ""
 


Test patch:
Repository: urllib3/urllib3

Issue:
Default blocksize inconsistencies between PoolManager and HttpConn
Witnessed that behavior when debugging the network stack, I saw blocks of different sizes whenever I instantiated the conn or passed via the poolmanager.

https://github.com/urllib3/urllib3/blob/7bdf9757c00e7935343ed6d4526683c1ed560052/src/urllib3/poolmanager.py#L52

https://github.com/urllib3/urllib3/blob/7bdf9757c00e7935343ed6d4526683c1ed560052/src/urllib3/connection.py#L137

Is there any adjustment required in your opinion?


Discussion:
iirc, the `blocksize` on connections is due to standard library. It might be okay to change it to our own default of 16kB?
will add a patch for it.

Resolving patch:
diff --git a/src/urllib3/_base_connection.py b/src/urllib3/_base_connection.py
--- a/src/urllib3/_base_connection.py
+++ b/src/urllib3/_base_connection.py
@@ -151,7 +151,7 @@ def __init__(
             *,
             timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT,
             source_address: tuple[str, int] | None = None,
-            blocksize: int = 8192,
+            blocksize: int = 16384,
             socket_options: _TYPE_SOCKET_OPTIONS | None = ...,
             proxy: Url | None = None,
             proxy_config: ProxyConfig | None = None,
diff --git a/src/urllib3/connection.py b/src/urllib3/connection.py
--- a/src/urllib3/connection.py
+++ b/src/urllib3/connection.py
@@ -137,7 +137,7 @@ def __init__(
         *,
         timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT,
         source_address: tuple[str, int] | None = None,
-        blocksize: int = 8192,
+        blocksize: int = 16384,
         socket_options: None
         | (connection._TYPE_SOCKET_OPTIONS) = default_socket_options,
         proxy: Url | None = None,
@@ -512,7 +512,7 @@ def __init__(
         *,
         timeout: _TYPE_TIMEOUT = _DEFAULT_TIMEOUT,
         source_address: tuple[str, int] | None = None,
-        blocksize: int = 8192,
+        blocksize: int = 16384,
         socket_options: None
         | (connection._TYPE_SOCKET_OPTIONS) = HTTPConnection.default_socket_options,
         proxy: Url | None = None,


Test patch:
Repository: urllib3/urllib3

Issue:
Undeprecate pyOpenSSL third-party module
@pquentin, @illia-v and I discussed the current state of the pyOpenSSL module:

- There hasn't been any community effort that we know of to pull the pyOpenSSL module out of urllib3 and support it elsewhere.
- There hasn't been any addition to Python to support in-memory certificates
- Support for in-memory certificates is a major barrier to adoption of urllib3 v2.0
- pyOpenSSL support isn't a /ton/ of support burden, it isn't zero though. We will likely want to remove it if any of the above change.

For these reasons, we've decided to un-deprecate pyOpenSSL and not remove the `urllib3.contrib.pyopenssl` module in v2.1.0.


Discussion:

Resolving patch:
diff --git a/src/urllib3/contrib/pyopenssl.py b/src/urllib3/contrib/pyopenssl.py
--- a/src/urllib3/contrib/pyopenssl.py
+++ b/src/urllib3/contrib/pyopenssl.py
@@ -54,21 +54,12 @@ class UnsupportedExtension(Exception):  # type: ignore[no-redef]
 import logging
 import ssl
 import typing
-import warnings
 from io import BytesIO
 from socket import socket as socket_cls
 from socket import timeout
 
 from .. import util
 
-warnings.warn(
-    "'urllib3.contrib.pyopenssl' module is deprecated and will be removed "
-    "in urllib3 v2.1.0. Read more in this issue: "
-    "https://github.com/urllib3/urllib3/issues/2680",
-    category=DeprecationWarning,
-    stacklevel=2,
-)
-
 if typing.TYPE_CHECKING:
     from OpenSSL.crypto import X509  # type: ignore[import]
 


Test patch:
Repository: urllib3/urllib3

Issue:
[1.26] GHA Python 2 support ended on June 17th
Warning: The support for python 2.7 will be removed on June 19. Related issue: https://github.com/actions/setup-python/issues/672


Discussion:

Resolving patch:
diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -55,7 +55,8 @@ def google_brotli(session):
     # https://pypi.org/project/Brotli/ is the Google version of brotli, so
     # install it separately and don't install our brotli extra (which installs
     # brotlipy).
-    session.install("brotli")
+    # https://github.com/google/brotli/issues/1074
+    session.install("brotli==1.0.9" if session.python == "2.7" else "brotli")
     tests_impl(session, extras="socks,secure")
 
 
diff --git a/src/urllib3/connection.py b/src/urllib3/connection.py
--- a/src/urllib3/connection.py
+++ b/src/urllib3/connection.py
@@ -437,7 +437,7 @@ def connect(self):
             and self.ssl_version is None
             and hasattr(self.sock, "version")
             and self.sock.version() in {"TLSv1", "TLSv1.1"}
-        ):
+        ):  # Defensive:
             warnings.warn(
                 "Negotiating TLSv1/TLSv1.1 by default is deprecated "
                 "and will be disabled in urllib3 v2.0.0. Connecting to "


Test patch:
diff --git a/ci/run_tests.sh b/ci/run_tests.sh
--- a/ci/run_tests.sh
+++ b/ci/run_tests.sh
@@ -3,7 +3,7 @@
 
 if [[ "${NOX_SESSION}" == "app_engine" ]]; then
     export GAE_SDK_PATH=$HOME/.cache/google_appengine
-    python2 -m pip install gcp-devrel-py-tools==0.0.16
+    python2.7 -m pip install gcp-devrel-py-tools==0.0.16
     gcp-devrel-py-tools download-appengine-sdk "$(dirname ${GAE_SDK_PATH})"
 fi
Repository: urllib3/urllib3

Issue:
Cannot pass ssl kwarg cert_data in proxy context
Discovered that one while writting tls-in-tls http/2 tests in #3030 

While we can do

```python
with proxy_from_url("...", ca_certs=DEFAULT_CA) as http:
    ...
```

we cannot 

```python
with proxy_from_url("...", cert_data=open(DEFAULT_CA, "rb").read()) as http:
    ...
```

output `unexpected kw key_cert_data for pool conn`

I suspect that we missed propagating required kw.

It is an easy fix.

should patch `SSL_KEYWORDS = (....)` and `class PoolKey(typing.NamedTuple):`


Discussion:
will try to add a PR for this.

Resolving patch:
diff --git a/src/urllib3/poolmanager.py b/src/urllib3/poolmanager.py
--- a/src/urllib3/poolmanager.py
+++ b/src/urllib3/poolmanager.py
@@ -38,6 +38,7 @@
     "cert_file",
     "cert_reqs",
     "ca_certs",
+    "ca_cert_data",
     "ssl_version",
     "ssl_minimum_version",
     "ssl_maximum_version",
@@ -73,6 +74,7 @@ class PoolKey(typing.NamedTuple):
     key_cert_file: str | None
     key_cert_reqs: str | None
     key_ca_certs: str | None
+    key_ca_cert_data: str | bytes | None
     key_ssl_version: int | str | None
     key_ssl_minimum_version: ssl.TLSVersion | None
     key_ssl_maximum_version: ssl.TLSVersion | None


Test patch:
diff --git a/test/with_dummyserver/test_proxy_poolmanager.py b/test/with_dummyserver/test_proxy_poolmanager.py
--- a/test/with_dummyserver/test_proxy_poolmanager.py
+++ b/test/with_dummyserver/test_proxy_poolmanager.py
@@ -78,6 +78,16 @@ def test_https_proxy(self) -> None:
             r = https.request("GET", f"{self.http_url}/")
             assert r.status == 200
 
+    def test_http_and_https_kwarg_ca_cert_data_proxy(self) -> None:
+        with open(DEFAULT_CA) as pem_file:
+            pem_file_data = pem_file.read()
+        with proxy_from_url(self.https_proxy_url, ca_cert_data=pem_file_data) as https:
+            r = https.request("GET", f"{self.https_url}/")
+            assert r.status == 200
+
+            r = https.request("GET", f"{self.http_url}/")
+            assert r.status == 200
+
     def test_https_proxy_with_proxy_ssl_context(self) -> None:
         proxy_ssl_context = create_urllib3_context()
         proxy_ssl_context.load_verify_locations(DEFAULT_CA)
Repository: urllib3/urllib3

Issue:
How to implement a "watcher" thread as suggested by the documentation?
The documentation of the [`timeout`](https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#module-urllib3.util.timeout) module says:

> If your goal is to cut off any request after a set amount of wall clock time, consider having a second “watcher” thread to cut off a slow request.

How would that work?

It seems like it is [strongly discouraged or even impossible](https://stackoverflow.com/questions/323972/is-there-any-way-to-kill-a-thread) to kill a thread in Python, so what would that watcher thread do?

If it is not possible to write a watcher thread in Python, the documentation shouldn't suggest to do it.


Discussion:
This is a great question. I guess you're right! There's no good way to cut off a request after a set amount of time with urllib3, and we should acknowledge that. 

(This is actually a benefit of libraries based on async I/O such as trio, they support such global timeouts natively without needing cooperation from the HTTP library.)

Would you like to open a pull request to remove this sentence from the documentation?

There is a way, without using second thread. First you should use `Timeout(read=...)` to limit time on reading one network chunk, second you should read response by chunks and check elapsed time after each chunk has been received.
Also you can use gevent instead of native threads and wrap network operations into `gevent.Timeout`

Resolving patch:
diff --git a/src/urllib3/util/timeout.py b/src/urllib3/util/timeout.py
--- a/src/urllib3/util/timeout.py
+++ b/src/urllib3/util/timeout.py
@@ -101,10 +101,6 @@ class Timeout:
         the case; if a server streams one byte every fifteen seconds, a timeout
         of 20 seconds will not trigger, even though the request will take
         several minutes to complete.
-
-        If your goal is to cut off any request after a set amount of wall clock
-        time, consider having a second "watcher" thread to cut off a slow
-        request.
     """
 
     #: A sentinel object representing the default timeout value


Test patch: