Add type hints to test.with_dummyserver.test_connectionpool
MODIFY
noxfile.py
noxfile.py
@@ -167,6 +167,7 @@ def mypy(session: nox.Session) -> None:
"noxfile.py",
"src/urllib3",
"test/__init__.py",
+ "test/with_dummyserver/test_connectionpool.py",
"test/with_dummyserver/test_chunked_transfer.py",
"test/with_dummyserver/test_https.py",
"test/with_dummyserver/test_integration.py",

MODIFY
src/urllib3/filepost.py
src/urllib3/filepost.py
@@ -2,7 +2,7 @@ import binascii
import codecs
import os
from io import BytesIO
-from typing import Dict, Iterable, Optional, Sequence, Tuple, Union
+from typing import Iterable, Mapping, Optional, Sequence, Tuple, Union
from .fields import _TYPE_FIELD_VALUE_TUPLE, RequestField
@@ -13,7 +13,7 @@ _TYPE_FIELDS_SEQUENCE = Sequence[
]
_TYPE_FIELDS = Union[
_TYPE_FIELDS_SEQUENCE,
- Dict[str, _TYPE_FIELD_VALUE_TUPLE],
+ Mapping[str, _TYPE_FIELD_VALUE_TUPLE],
]
@@ -34,7 +34,7 @@ def iter_field_objects(fields: _TYPE_FIELDS) -> Iterable[RequestField]:
"""
iterable: Iterable[Union[RequestField, Tuple[str, _TYPE_FIELD_VALUE_TUPLE]]]
- if isinstance(fields, dict):
+ if isinstance(fields, Mapping):
iterable = fields.items()
else:
iterable = fields

MODIFY
src/urllib3/response.py
src/urllib3/response.py
@@ -201,6 +201,7 @@ class BaseHTTPResponse(io.IOBase):
reason: Optional[str],
decode_content: bool,
request_url: Optional[str],
+ retries: Optional[Retry] = None,
) -> None:
if isinstance(headers, HTTPHeaderDict):
self.headers = headers
@@ -211,6 +212,7 @@ class BaseHTTPResponse(io.IOBase):
self.reason = reason
self.decode_content = decode_content
self.request_url: Optional[str]
+ self.retries = retries
self.chunked = False
tr_enc = self.headers.get("transfer-encoding", "").lower()
@@ -429,9 +431,9 @@ class HTTPResponse(BaseHTTPResponse):
reason=reason,
decode_content=decode_content,
request_url=request_url,
+ retries=retries,
)
- self.retries = retries
self.enforce_content_length = enforce_content_length
self.auto_close = auto_close

Add type hints to test.with_dummyserver.test_connectionpool