Skip to content
Myr

Define and expose the API from the same place (#3106)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Tidy up imports * Update tests/test_exported_members.py ---------

authored by Kar Petrosyan · committed by GitHub · parent 77cb36f · Browse files · 18 files+101 added−44 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Tom Christie <tom@tomchristie.com>

Diff stats

18 files+101 added−44 removed

  • other:+101 added−44 removed

18 files+101 added−44 removed

modified:httpx/_transports/__init__.py+15 added
1from .asgi import *2from .base import *3from .default import *4from .mock import *5from .wsgi import *67__all__ = [8 "ASGITransport",9 "AsyncBaseTransport",10 "BaseTransport",11 "AsyncHTTPTransport",12 "HTTPTransport",13 "MockTransport",14 "WSGITransport",15]
modified:httpx/_transports/asgi.py+2 added
23 unmodified lines
24_ASGIApp = typing.Callable[25 [typing.Dict[str, typing.Any], _Receive, _Send], typing.Coroutine[None, None, None]26]2728__all__ = ["ASGITransport"]293031def create_event() -> Event:32 if sniffio.current_async_library() == "trio":33 import trio34
149 unmodified lines
modified:httpx/_transports/base.py+2 added
6 unmodified lines
78T = typing.TypeVar("T", bound="BaseTransport")9A = typing.TypeVar("A", bound="AsyncBaseTransport")1011__all__ = ["AsyncBaseTransport", "BaseTransport"]121314class BaseTransport:15 def __enter__(self: T) -> T:16 return self17
69 unmodified lines
modified:httpx/_transports/default.py+2 added
60 unmodified lines
61 typing.Tuple[int, int, typing.Union[bytes, bytearray]],62 typing.Tuple[int, int, None, int],63]6465__all__ = ["AsyncHTTPTransport", "HTTPTransport"]666768@contextlib.contextmanager69def map_httpcore_exceptions() -> typing.Iterator[None]:70 try:71 yield
316 unmodified lines
modified:httpx/_transports/mock.py+3 added
7 unmodified lines
8SyncHandler = typing.Callable[[Request], Response]9AsyncHandler = typing.Callable[[Request], typing.Coroutine[None, None, Response]]101112__all__ = ["MockTransport"]131415class MockTransport(AsyncBaseTransport, BaseTransport):16 def __init__(self, handler: SyncHandler | AsyncHandler) -> None:17 self.handler = handler18
25 unmodified lines
modified:httpx/_transports/wsgi.py+3 added
14 unmodified lines
1516_T = typing.TypeVar("_T")171819__all__ = ["WSGITransport"]202122def _skip_leading_empty_chunks(body: typing.Iterable[_T]) -> typing.Iterable[_T]:23 body = iter(body)24 for chunk in body:25 if chunk:
124 unmodified lines
modified:httpx/__init__.py+11 added-44 removed
1from .__version__ import __description__, __title__, __version__2from ._api import delete, get, head, options, patch, post, put, request, stream3from ._auth import Auth, BasicAuth, DigestAuth, NetRCAuth4from ._client import USE_CLIENT_DEFAULT, AsyncClient, Client5from ._config import Limits, Proxy, Timeout, create_ssl_context6from ._content import ByteStream7from ._exceptions import (8 CloseError,9 ConnectError,10 ConnectTimeout,11 CookieConflict,12 DecodingError,13 HTTPError,14 HTTPStatusError,15 InvalidURL,16 LocalProtocolError,17 NetworkError,18 PoolTimeout,19 ProtocolError,20 ProxyError,21 ReadError,22 ReadTimeout,23 RemoteProtocolError,24 RequestError,25 RequestNotRead,26 ResponseNotRead,27 StreamClosed,28 StreamConsumed,29 StreamError,30 TimeoutException,31 TooManyRedirects,32 TransportError,33 UnsupportedProtocol,34 WriteError,35 WriteTimeout,36)37from ._models import Cookies, Headers, Request, Response38from ._status_codes import codes39from ._transports.asgi import ASGITransport40from ._transports.base import AsyncBaseTransport, BaseTransport41from ._transports.default import AsyncHTTPTransport, HTTPTransport42from ._transports.mock import MockTransport43from ._transports.wsgi import WSGITransport44from ._types import AsyncByteStream, SyncByteStream45from ._urls import URL, QueryParams2from ._api import *3from ._auth import *4from ._client import *5from ._config import *6from ._content import *7from ._exceptions import *8from ._models import *9from ._status_codes import *10from ._transports import *11from ._types import *12from ._urls import *1314try:15 from ._main import main16except ImportError: # pragma: no cover
89 unmodified lines
modified:httpx/_api.py+12 added
20 unmodified lines
21 URLTypes,22 VerifyTypes,23)2425__all__ = [26 "delete",27 "get",28 "head",29 "options",30 "patch",31 "post",32 "put",33 "request",34 "stream",35]363738def request(39 method: str,40 url: URLTypes,41 *,
438 unmodified lines
modified:httpx/_auth.py+3 added
14 unmodified lines
15if typing.TYPE_CHECKING: # pragma: no cover16 from hashlib import _Hash171819__all__ = ["Auth", "BasicAuth", "DigestAuth", "NetRCAuth"]202122class Auth:23 """24 Base class for all authentication schemes.25
323 unmodified lines
modified:httpx/_client.py+2 added
56 unmodified lines
57 is_https_redirect,58 same_origin,59)6061__all__ = ["USE_CLIENT_DEFAULT", "AsyncClient", "Client"]6263# The type annotation for @classmethod and context managers here follows PEP 48464# https://www.python.org/dev/peps/pep-0484/#annotating-instance-and-class-methods65T = typing.TypeVar("T", bound="Client")66U = typing.TypeVar("U", bound="AsyncClient")
1988 unmodified lines
modified:httpx/_config.py+2 added
12 unmodified lines
13from ._types import CertTypes, HeaderTypes, TimeoutTypes, URLTypes, VerifyTypes14from ._urls import URL15from ._utils import get_ca_bundle_from_env1617__all__ = ["Limits", "Proxy", "Timeout", "create_ssl_context"]1819DEFAULT_CIPHERS = ":".join(20 [21 "ECDHE+AESGCM",22 "ECDHE+CHACHA20",
350 unmodified lines
modified:httpx/_content.py+2 added
23 unmodified lines
24 SyncByteStream,25)26from ._utils import peek_filelike_length, primitive_value_to_str2728__all__ = ["ByteStream"]293031class ByteStream(AsyncByteStream, SyncByteStream):32 def __init__(self, stream: bytes) -> None:33 self._stream = stream34
204 unmodified lines
modified:httpx/_exceptions.py+31 added
36 unmodified lines
3738if typing.TYPE_CHECKING:39 from ._models import Request, Response # pragma: no cover4041__all__ = [42 "CloseError",43 "ConnectError",44 "ConnectTimeout",45 "CookieConflict",46 "DecodingError",47 "HTTPError",48 "HTTPStatusError",49 "InvalidURL",50 "LocalProtocolError",51 "NetworkError",52 "PoolTimeout",53 "ProtocolError",54 "ProxyError",55 "ReadError",56 "ReadTimeout",57 "RemoteProtocolError",58 "RequestError",59 "RequestNotRead",60 "ResponseNotRead",61 "StreamClosed",62 "StreamConsumed",63 "StreamError",64 "TimeoutException",65 "TooManyRedirects",66 "TransportError",67 "UnsupportedProtocol",68 "WriteError",69 "WriteTimeout",70]717273class HTTPError(Exception):74 """75 Base class for `RequestError` and `HTTPStatusError`.76
302 unmodified lines
modified:httpx/_models.py+2 added
51 unmodified lines
52 parse_content_type_charset,53 parse_header_links,54)5556__all__ = ["Cookies", "Headers", "Request", "Response"]575859class Headers(typing.MutableMapping[str, str]):60 """61 HTTP headers, as a case-insensitive multi-dict.62 """
1149 unmodified lines
modified:httpx/_status_codes.py+2 added
1from __future__ import annotations23from enum import IntEnum45__all__ = ["codes"]678class codes(IntEnum):9 """HTTP status codes and reason phrases1011 Status codes from the following RFCs are all observed:
151 unmodified lines
modified:httpx/_types.py+2 added
106 unmodified lines
107RequestFiles = Union[Mapping[str, FileTypes], Sequence[Tuple[str, FileTypes]]]108109RequestExtensions = MutableMapping[str, Any]110111__all__ = ["AsyncByteStream", "SyncByteStream"]112113114class SyncByteStream:115 def __iter__(self) -> Iterator[bytes]:116 raise NotImplementedError(117 "The '__iter__' method must be implemented."
19 unmodified lines
modified:httpx/_urls.py+2 added
7 unmodified lines
8from ._types import QueryParamTypes, RawURL, URLTypes9from ._urlparse import urlencode, urlparse10from ._utils import primitive_value_to_str1112__all__ = ["URL", "QueryParams"]131415class URL:16 """17 url = httpx.URL("HTTPS://jo%40email.com:a%20secret@müller.de:1234/pa%20th?search=ab#anchorlink")18
630 unmodified lines
modified:pyproject.toml+3 added
99 unmodified lines
100101[tool.ruff.isort]102combine-as-imports = true103104[tool.ruff.lint.per-file-ignores]105"__init__.py" = ["F403", "F405"]106107[tool.mypy]108ignore_missing_imports = true109strict = true110
21 unmodified lines