## Unreleased
+### Added
+
+* Add missing type hints to few `__init__()` methods. (#2938)
+
## 0.25.1 (3rd November, 2023)
### Added
def __init__(
self, username: typing.Union[str, bytes], password: typing.Union[str, bytes]
- ):
+ ) -> None:
self._auth_header = self._build_auth_header(username, password)
def auth_flow(self, request: Request) -> typing.Generator[Request, Response, None]:
Use a 'netrc' file to lookup basic auth credentials based on the url host.
"""
- def __init__(self, file: typing.Optional[str] = None):
+ def __init__(self, file: typing.Optional[str] = None) -> None:
# Lazily import 'netrc'.
# There's no need for us to load this module unless 'NetRCAuth' is being used.
import netrc
base_url: URLTypes = "",
trust_env: bool = True,
default_encoding: typing.Union[str, typing.Callable[[bytes], str]] = "utf-8",
- ):
+ ) -> None:
event_hooks = {} if event_hooks is None else event_hooks
self._base_url = self._enforce_trailing_slash(URL(base_url))
app: typing.Optional[typing.Callable[..., typing.Any]] = None,
trust_env: bool = True,
default_encoding: typing.Union[str, typing.Callable[[bytes], str]] = "utf-8",
- ):
+ ) -> None:
super().__init__(
auth=auth,
params=params,
app: typing.Optional[typing.Callable[..., typing.Any]] = None,
trust_env: bool = True,
default_encoding: typing.Union[str, typing.Callable[[bytes], str]] = "utf-8",
- ):
+ ) -> None:
super().__init__(
auth=auth,
params=params,
verify: VerifyTypes = True,
trust_env: bool = True,
http2: bool = False,
- ):
+ ) -> None:
self.cert = cert
self.verify = verify
self.trust_env = trust_env
read: typing.Union[None, float, UnsetType] = UNSET,
write: typing.Union[None, float, UnsetType] = UNSET,
pool: typing.Union[None, float, UnsetType] = UNSET,
- ):
+ ) -> None:
if isinstance(timeout, Timeout):
# Passed as a single explicit Timeout.
assert connect is UNSET
max_connections: typing.Optional[int] = None,
max_keepalive_connections: typing.Optional[int] = None,
keepalive_expiry: typing.Optional[float] = 5.0,
- ):
+ ) -> None:
self.max_connections = max_connections
self.max_keepalive_connections = max_keepalive_connections
self.keepalive_expiry = keepalive_expiry
ssl_context: typing.Optional[ssl.SSLContext] = None,
auth: typing.Optional[typing.Tuple[str, str]] = None,
headers: typing.Optional[HeaderTypes] = None,
- ):
+ ) -> None:
url = URL(url)
headers = Headers(headers)
class IteratorByteStream(SyncByteStream):
CHUNK_SIZE = 65_536
- def __init__(self, stream: Iterable[bytes]):
+ def __init__(self, stream: Iterable[bytes]) -> None:
self._stream = stream
self._is_stream_consumed = False
self._is_generator = inspect.isgenerator(stream)
class AsyncIteratorByteStream(AsyncByteStream):
CHUNK_SIZE = 65_536
- def __init__(self, stream: AsyncIterable[bytes]):
+ def __init__(self, stream: AsyncIterable[bytes]) -> None:
self._stream = stream
self._is_stream_consumed = False
self._is_generator = inspect.isasyncgen(stream)
Handles incrementally decoding bytes into text
"""
- def __init__(self, encoding: str = "utf-8"):
+ def __init__(self, encoding: str = "utf-8") -> None:
self.decoder = codecs.getincrementaldecoder(encoding)(errors="replace")
def decode(self, data: bytes) -> str:
json: typing.Optional[typing.Any] = None,
stream: typing.Union[SyncByteStream, AsyncByteStream, None] = None,
extensions: typing.Optional[RequestExtensions] = None,
- ):
+ ) -> None:
self.method = (
method.decode("ascii").upper()
if isinstance(method, bytes)
extensions: typing.Optional[ResponseExtensions] = None,
history: typing.Optional[typing.List["Response"]] = None,
default_encoding: typing.Union[str, typing.Callable[[bytes], str]] = "utf-8",
- ):
+ ) -> None:
self.status_code = status_code
self.headers = Headers(headers)
for use with `CookieJar` operations.
"""
- def __init__(self, response: Response):
+ def __init__(self, response: Response) -> None:
self.response = response
def info(self) -> email.message.Message:
class ResponseStream(SyncByteStream):
- def __init__(self, httpcore_stream: typing.Iterable[bytes]):
+ def __init__(self, httpcore_stream: typing.Iterable[bytes]) -> None:
self._httpcore_stream = httpcore_stream
def __iter__(self) -> typing.Iterator[bytes]:
class AsyncResponseStream(AsyncByteStream):
- def __init__(self, httpcore_stream: typing.AsyncIterable[bytes]):
+ def __init__(self, httpcore_stream: typing.AsyncIterable[bytes]) -> None:
self._httpcore_stream = httpcore_stream
async def __aiter__(self) -> typing.AsyncIterator[bytes]:
@pytest.mark.anyio
async def test_context_managed_transport_and_mount():
class Transport(httpx.AsyncBaseTransport):
- def __init__(self, name: str):
+ def __init__(self, name: str) -> None:
self.name: str = name
self.events: typing.List[str] = []
requires_request_body = True
- def __init__(self, repeat: int):
+ def __init__(self, repeat: int) -> None:
self.repeat = repeat
def auth_flow(
def test_context_managed_transport_and_mount():
class Transport(httpx.BaseTransport):
- def __init__(self, name: str):
+ def __init__(self, name: str) -> None:
self.name: str = name
self.events: typing.List[str] = []