Repository: urllib3/urllib3

Issue:
Tolerate the strict parameter being passed via connection_from_context()
If we test Requests against urllib3 `main` branch we receive the following:

```
  File "/home/sethmlarson/urllib3/src/urllib3/poolmanager.py", line 354, in connection_from_url
    return self.connection_from_host(
  File "/home/sethmlarson/urllib3/src/urllib3/poolmanager.py", line 294, in connection_from_host
    return self.connection_from_context(request_context)
  File "/home/sethmlarson/urllib3/src/urllib3/poolmanager.py", line 310, in connection_from_context
    pool_key = pool_key_constructor(request_context)
  File "/home/sethmlarson/urllib3/src/urllib3/poolmanager.py", line 143, in _default_key_normalizer
    return key_class(**context)
TypeError: __new__() got an unexpected keyword argument 'key_strict'
```

This started in https://github.com/urllib3/urllib3/pull/2064. One of the goals of v2 is to be mostly API compatible so downstream projects can immediately start using v2. Should we add the following within `PoolManager.connection_from_context`?

```python
        if "strict" in request_context:
            import warnings

            warnings.warn(
                "The 'strict' parameter is no longer needed on Python 3+. "
                "This will raise an error in urllib3 v3.0.0.",
                DeprecationWarning
            )
            request_context.pop("strict")
```

to maintain API compatibility with Requests and other libraries that support Python 2?

Another small thought is to add a simple integration test with `requests.get(...)` to our test suite so we can track that we don't lose complete API compatibility.



Discussion:
> Should we add the following within PoolManager.connection_from_context?

Yes, if we are going to be mostly compatible.

> Another small thought is to add a simple integration test with requests.get(...) to our test suite so we can track that we don't lose complete API compatibility.

Good point :+1: 

I can work on 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
@@ -1,5 +1,6 @@
 import functools
 import logging
+import warnings
 from typing import (
     TYPE_CHECKING,
     Any,
@@ -302,6 +303,14 @@ def connection_from_context(
         ``request_context`` must at least contain the ``scheme`` key and its
         value must be a key in ``key_fn_by_scheme`` instance variable.
         """
+        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.",
+                DeprecationWarning,
+            )
+            request_context.pop("strict")
+
         scheme = request_context["scheme"].lower()
         pool_key_constructor = self.key_fn_by_scheme.get(scheme)
         if not pool_key_constructor:


Test patch:
diff --git a/test/test_poolmanager.py b/test/test_poolmanager.py
--- a/test/test_poolmanager.py
+++ b/test/test_poolmanager.py
@@ -1,5 +1,6 @@
 import socket
 from test import resolvesLocalhostFQDN
+from unittest.mock import patch
 
 import pytest
 
@@ -267,6 +268,32 @@ def test_http_connection_from_context_case_insensitive(self):
         assert pool is other_pool
         assert all(isinstance(key, PoolKey) for key in p.pools.keys())
 
+    @patch("urllib3.poolmanager.PoolManager.connection_from_pool_key")
+    def test_connection_from_context_strict_param(self, connection_from_pool_key):
+        p = PoolManager()
+        context = {
+            "scheme": "http",
+            "host": "example.com",
+            "port": 8080,
+            "strict": True,
+        }
+        with pytest.warns(DeprecationWarning) as record:
+            p.connection_from_context(context)
+
+        assert 1 == len(record)
+        msg = (
+            "The 'strict' parameter is no longer needed on Python 3+. "
+            "This will raise an error in urllib3 v3.0.0."
+        )
+        assert record[0].message.args[0] == msg
+
+        _, kwargs = connection_from_pool_key.call_args
+        assert kwargs["request_context"] == {
+            "scheme": "http",
+            "host": "example.com",
+            "port": 8080,
+        }
+
     def test_custom_pool_key(self):
         """Assert it is possible to define a custom key function."""
         p = PoolManager(10)
diff --git a/test/with_dummyserver/test_integration.py b/test/with_dummyserver/test_integration.py
new file mode 100644
--- /dev/null
+++ b/test/with_dummyserver/test_integration.py
@@ -0,0 +1,35 @@
+import pytest
+import requests
+
+from dummyserver.server import DEFAULT_CA
+from dummyserver.testcase import HTTPDummyServerTestCase, HTTPSDummyServerTestCase
+
+
+class TestHTTPIntegration(HTTPDummyServerTestCase):
+    def test_requests_integration(self):
+        with pytest.warns(DeprecationWarning) as record:
+            response = requests.get(f"{self.scheme}://{self.host}:{self.port}")
+
+        assert 200 == response.status_code
+        assert 1 == len(record)
+        msg = (
+            "The 'strict' parameter is no longer needed on Python 3+. "
+            "This will raise an error in urllib3 v3.0.0."
+        )
+        assert record[0].message.args[0] == msg
+
+
+class TestHTTPSIntegration(HTTPSDummyServerTestCase):
+    def test_requests_integration(self):
+        with pytest.warns(DeprecationWarning) as record:
+            response = requests.get(
+                f"{self.scheme}://{self.host}:{self.port}", verify=DEFAULT_CA
+            )
+
+        assert 200 == response.status_code
+        assert 1 == len(record)
+        msg = (
+            "The 'strict' parameter is no longer needed on Python 3+. "
+            "This will raise an error in urllib3 v3.0.0."
+        )
+        assert record[0].message.args[0] == msg