summaryrefslogtreecommitdiff
path: root/src/urllib3/util
diff options
context:
space:
mode:
authorVishwas B Sharma <1235813+csurfer@users.noreply.github.com>2021-06-21 07:05:59 -0700
committerGitHub <noreply@github.com>2021-06-21 09:05:59 -0500
commit89ca490bfc15b7b4762676b5b51bf57e8912d80f (patch)
tree77f422f5400a3005aa61be732032d7fa90c0e5cc /src/urllib3/util
parent74783abf8c9ab4e86fd18adefb4100d146eee5dc (diff)
downloadurllib3-89ca490bfc15b7b4762676b5b51bf57e8912d80f.tar.gz
Make all type aliases private and the same format
Diffstat (limited to 'src/urllib3/util')
-rw-r--r--src/urllib3/util/connection.py8
-rw-r--r--src/urllib3/util/ssl_.py4
-rw-r--r--src/urllib3/util/ssl_match_hostname.py4
-rw-r--r--src/urllib3/util/ssltransport.py8
4 files changed, 13 insertions, 11 deletions
diff --git a/src/urllib3/util/connection.py b/src/urllib3/util/connection.py
index 5f4be134..f4204189 100644
--- a/src/urllib3/util/connection.py
+++ b/src/urllib3/util/connection.py
@@ -6,7 +6,7 @@ from urllib3.exceptions import LocationParseError
from .wait import wait_for_read
SOCKET_GLOBAL_DEFAULT_TIMEOUT = socket._GLOBAL_DEFAULT_TIMEOUT # type: ignore
-SocketOptions = Sequence[Tuple[int, int, Union[int, bytes]]]
+_TYPE_SOCKET_OPTIONS = Sequence[Tuple[int, int, Union[int, bytes]]]
def is_connection_dropped(conn: socket.socket) -> bool: # Platform-specific
@@ -31,7 +31,7 @@ def create_connection(
address: Tuple[str, int],
timeout: Optional[float] = SOCKET_GLOBAL_DEFAULT_TIMEOUT,
source_address: Optional[Tuple[str, int]] = None,
- socket_options: Optional[SocketOptions] = None,
+ socket_options: Optional[_TYPE_SOCKET_OPTIONS] = None,
) -> socket.socket:
"""Connect to *address* and return the socket object.
@@ -93,7 +93,9 @@ def create_connection(
raise OSError("getaddrinfo returns an empty list")
-def _set_socket_options(sock: socket.socket, options: Optional[SocketOptions]) -> None:
+def _set_socket_options(
+ sock: socket.socket, options: Optional[_TYPE_SOCKET_OPTIONS]
+) -> None:
if options is None:
return
diff --git a/src/urllib3/util/ssl_.py b/src/urllib3/util/ssl_.py
index 63516536..02f35aa5 100644
--- a/src/urllib3/util/ssl_.py
+++ b/src/urllib3/util/ssl_.py
@@ -72,8 +72,8 @@ except ImportError:
_PCTRTT = Tuple[Tuple[str, str], ...]
_PCTRTTT = Tuple[_PCTRTT, ...]
-PeerCertRetDictType = Dict[str, Union[str, _PCTRTTT, _PCTRTT]]
-PeerCertRetType = Union[PeerCertRetDictType, bytes, None]
+_TYPE_PEER_CERT_RET_DICT = Dict[str, Union[str, _PCTRTTT, _PCTRTT]]
+_TYPE_PEER_CERT_RET = Union[_TYPE_PEER_CERT_RET_DICT, bytes, None]
# A secure default.
diff --git a/src/urllib3/util/ssl_match_hostname.py b/src/urllib3/util/ssl_match_hostname.py
index 9f68ac54..8055285a 100644
--- a/src/urllib3/util/ssl_match_hostname.py
+++ b/src/urllib3/util/ssl_match_hostname.py
@@ -7,7 +7,7 @@ import ipaddress
import re
from typing import Any, Match, Optional, Union
-from .ssl_ import PeerCertRetType
+from .ssl_ import _TYPE_PEER_CERT_RET
__version__ = "3.5.0.1"
@@ -84,7 +84,7 @@ def _ipaddress_match(ipname: Any, host_ip: str) -> bool:
return bool(ip == host_ip)
-def match_hostname(cert: PeerCertRetType, hostname: str) -> None:
+def match_hostname(cert: _TYPE_PEER_CERT_RET, hostname: str) -> None:
"""Verify that *cert* (in decoded format as returned by
SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125
rules are followed, but IP addresses are not accepted for *hostname*.
diff --git a/src/urllib3/util/ssltransport.py b/src/urllib3/util/ssltransport.py
index ded5b749..d18a8d92 100644
--- a/src/urllib3/util/ssltransport.py
+++ b/src/urllib3/util/ssltransport.py
@@ -22,7 +22,7 @@ if TYPE_CHECKING:
from typing_extensions import Literal
- from .ssl_ import PeerCertRetDictType, PeerCertRetType
+ from .ssl_ import _TYPE_PEER_CERT_RET, _TYPE_PEER_CERT_RET_DICT
_SelfT = TypeVar("_SelfT", bound="SSLTransport")
@@ -186,7 +186,7 @@ class SSLTransport:
@overload
def getpeercert(
self, binary_form: "Literal[False]" = ...
- ) -> Optional["PeerCertRetDictType"]:
+ ) -> Optional["_TYPE_PEER_CERT_RET_DICT"]:
...
@overload
@@ -194,12 +194,12 @@ class SSLTransport:
...
@overload
- def getpeercert(self, binary_form: bool) -> "PeerCertRetType":
+ def getpeercert(self, binary_form: bool) -> "_TYPE_PEER_CERT_RET":
...
def getpeercert(
self, binary_form: bool = False
- ) -> Union[None, bytes, "PeerCertRetDictType", "PeerCertRetType"]:
+ ) -> Union[None, bytes, "_TYPE_PEER_CERT_RET_DICT", "_TYPE_PEER_CERT_RET"]:
return self.sslobj.getpeercert(binary_form)
def version(self) -> Optional[str]: