Remove the 'urllib3.request' module
ADD
changelog/2269.removal.rst
+Removed the ``urllib3.request`` module. ``urllib3.request.RequestMethods`` has been made a private API.
+
+This change was made to ensure that ``from urllib3 import request`` imported the top-level ``request()``
+function instead of the ``urllib3.request`` module.
\ No newline at end of file

MODIFY
docs/reference/index.rst
docs/reference/index.rst
@@ -9,6 +9,5 @@ API Reference
urllib3.exceptions
urllib3.response
urllib3.fields
- urllib3.request
urllib3.util
contrib/index

DELETE
docs/reference/urllib3.request.rst
-Request Methods
-===============
-
-.. automodule:: urllib3.request
- :members:
- :undoc-members:
- :show-inheritance:

RENAME
src/urllib3/request.py
src/urllib3/_request_methods.py
MODIFY
src/urllib3/connectionpool.py
src/urllib3/connectionpool.py
@@ -9,6 +9,7 @@ from socket import timeout as SocketTimeout
from types import TracebackType
from typing import TYPE_CHECKING, Any, Mapping, Optional, Type, TypeVar, Union, overload
+from ._request_methods import RequestMethods
from .connection import (
_TYPE_BODY,
BaseSSLError,
@@ -38,7 +39,6 @@ from .exceptions import (
SSLError,
TimeoutError,
)
-from .request import RequestMethods
from .response import BaseHTTPResponse, HTTPResponse
from .util.connection import is_connection_dropped
from .util.proxy import connection_requires_http_tunnel

MODIFY
src/urllib3/poolmanager.py
src/urllib3/poolmanager.py
@@ -18,6 +18,7 @@ from typing import (
from urllib.parse import urljoin
from ._collections import RecentlyUsedContainer
+from ._request_methods import RequestMethods
from .connection import ProxyConfig
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, port_by_scheme
from .exceptions import (
@@ -26,7 +27,6 @@ from .exceptions import (
ProxySchemeUnknown,
URLSchemeUnknown,
)
-from .request import RequestMethods
from .response import BaseHTTPResponse
from .util.connection import _TYPE_SOCKET_OPTIONS
from .util.proxy import connection_requires_http_tunnel

Remove the 'urllib3.request' module (#2398)