Add self type to requests.Session.__enter__ (#5620)

Fixes microsoft/pyright#1976
This commit is contained in:
Jelle Zijlstra
2021-06-11 07:48:48 -07:00
committed by GitHub
parent e66ceceed0
commit 967d0b2167

View File

@@ -1,5 +1,5 @@
from _typeshed import SupportsItems
from typing import IO, Any, Callable, Iterable, List, Mapping, MutableMapping, Optional, Text, Tuple, Union
from typing import IO, Any, Callable, Iterable, List, Mapping, MutableMapping, Optional, Text, Tuple, TypeVar, Union
from . import adapters, auth as _auth, compat, cookies, exceptions, hooks, models, status_codes, structures, utils
from .models import Response
@@ -57,6 +57,7 @@ _Params = Union[
Iterable[Tuple[_ParamsMappingKeyType, _ParamsMappingValueType]],
Union[Text, bytes],
]
_SessionT = TypeVar("_SessionT", bound=Session)
class Session(SessionRedirectMixin):
__attrs__: Any
@@ -74,7 +75,7 @@ class Session(SessionRedirectMixin):
adapters: MutableMapping[Any, Any]
redirect_cache: RecentlyUsedContainer[Any, Any]
def __init__(self) -> None: ...
def __enter__(self) -> Session: ...
def __enter__(self: _SessionT) -> _SessionT: ...
def __exit__(self, *args) -> None: ...
def prepare_request(self, request): ...
def request(