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
Provenance
- Commit
87713d2- Tree
b56d071- Author
Kar Petrosyan <92274156+karpetrosyan@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
77cb36f
18 files changed+101 added−44 removed
modified:httpx/_transports/__init__.py+15 added
1+from .asgi import *2+from .base import *3+from .default import *4+from .mock import *5+from .wsgi import *6+7+__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 lines24 _ASGIApp = typing.Callable[25 [typing.Dict[str, typing.Any], _Receive, _Send], typing.Coroutine[None, None, None]26 ]27 28+__all__ = ["ASGITransport"]29 30+31 def create_event() -> Event:32 if sniffio.current_async_library() == "trio":33 import trio34 149 unmodified linesmodified:httpx/_transports/base.py+2 added
6 unmodified lines7 8 T = typing.TypeVar("T", bound="BaseTransport")9 A = typing.TypeVar("A", bound="AsyncBaseTransport")10 11+__all__ = ["AsyncBaseTransport", "BaseTransport"]12 13+14 class BaseTransport:15 def __enter__(self: T) -> T:16 return self17 69 unmodified linesmodified:httpx/_transports/default.py+2 added
60 unmodified lines61 typing.Tuple[int, int, typing.Union[bytes, bytearray]],62 typing.Tuple[int, int, None, int],63 ]64 65+__all__ = ["AsyncHTTPTransport", "HTTPTransport"]66 67+68 @contextlib.contextmanager69 def map_httpcore_exceptions() -> typing.Iterator[None]:70 try:71 yield316 unmodified linesmodified:httpx/_transports/mock.py+3 added
7 unmodified lines8 SyncHandler = typing.Callable[[Request], Response]9 AsyncHandler = typing.Callable[[Request], typing.Coroutine[None, None, Response]]10 11 12+__all__ = ["MockTransport"]13+14+15 class MockTransport(AsyncBaseTransport, BaseTransport):16 def __init__(self, handler: SyncHandler | AsyncHandler) -> None:17 self.handler = handler18 25 unmodified linesmodified:httpx/_transports/wsgi.py+3 added
14 unmodified lines15 16 _T = typing.TypeVar("_T")17 18 19+__all__ = ["WSGITransport"]20+21+22 def _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 linesmodified:httpx/__init__.py+11 added-44 removed
1 from .__version__ import __description__, __title__, __version__2-from ._api import delete, get, head, options, patch, post, put, request, stream3-from ._auth import Auth, BasicAuth, DigestAuth, NetRCAuth4-from ._client import USE_CLIENT_DEFAULT, AsyncClient, Client5-from ._config import Limits, Proxy, Timeout, create_ssl_context6-from ._content import ByteStream7-from ._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-)37-from ._models import Cookies, Headers, Request, Response38-from ._status_codes import codes39-from ._transports.asgi import ASGITransport40-from ._transports.base import AsyncBaseTransport, BaseTransport41-from ._transports.default import AsyncHTTPTransport, HTTPTransport42-from ._transports.mock import MockTransport43-from ._transports.wsgi import WSGITransport44-from ._types import AsyncByteStream, SyncByteStream45-from ._urls import URL, QueryParams2+from ._api import *3+from ._auth import *4+from ._client import *5+from ._config import *6+from ._content import *7+from ._exceptions import *8+from ._models import *9+from ._status_codes import *10+from ._transports import *11+from ._types import *12+from ._urls import *13 14 try:15 from ._main import main16 except ImportError: # pragma: no cover89 unmodified linesmodified:httpx/_api.py+12 added
20 unmodified lines21 URLTypes,22 VerifyTypes,23 )24 25+__all__ = [26+ "delete",27+ "get",28+ "head",29+ "options",30+ "patch",31+ "post",32+ "put",33+ "request",34+ "stream",35+]36 37+38 def request(39 method: str,40 url: URLTypes,41 *,438 unmodified linesmodified:httpx/_auth.py+3 added
14 unmodified lines15 if typing.TYPE_CHECKING: # pragma: no cover16 from hashlib import _Hash17 18 19+__all__ = ["Auth", "BasicAuth", "DigestAuth", "NetRCAuth"]20+21+22 class Auth:23 """24 Base class for all authentication schemes.25 323 unmodified linesmodified:httpx/_client.py+2 added
56 unmodified lines57 is_https_redirect,58 same_origin,59 )60 61+__all__ = ["USE_CLIENT_DEFAULT", "AsyncClient", "Client"]62+63 # The type annotation for @classmethod and context managers here follows PEP 48464 # https://www.python.org/dev/peps/pep-0484/#annotating-instance-and-class-methods65 T = typing.TypeVar("T", bound="Client")66 U = typing.TypeVar("U", bound="AsyncClient")1988 unmodified linesmodified:httpx/_config.py+2 added
12 unmodified lines13 from ._types import CertTypes, HeaderTypes, TimeoutTypes, URLTypes, VerifyTypes14 from ._urls import URL15 from ._utils import get_ca_bundle_from_env16 17+__all__ = ["Limits", "Proxy", "Timeout", "create_ssl_context"]18+19 DEFAULT_CIPHERS = ":".join(20 [21 "ECDHE+AESGCM",22 "ECDHE+CHACHA20",350 unmodified linesmodified:httpx/_content.py+2 added
23 unmodified lines24 SyncByteStream,25 )26 from ._utils import peek_filelike_length, primitive_value_to_str27 28+__all__ = ["ByteStream"]29 30+31 class ByteStream(AsyncByteStream, SyncByteStream):32 def __init__(self, stream: bytes) -> None:33 self._stream = stream34 204 unmodified linesmodified:httpx/_exceptions.py+31 added
36 unmodified lines37 38 if typing.TYPE_CHECKING:39 from ._models import Request, Response # pragma: no cover40 41+__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+]71 72+73 class HTTPError(Exception):74 """75 Base class for `RequestError` and `HTTPStatusError`.76 302 unmodified linesmodified:httpx/_models.py+2 added
51 unmodified lines52 parse_content_type_charset,53 parse_header_links,54 )55 56+__all__ = ["Cookies", "Headers", "Request", "Response"]57 58+59 class Headers(typing.MutableMapping[str, str]):60 """61 HTTP headers, as a case-insensitive multi-dict.62 """1149 unmodified linesmodified:httpx/_status_codes.py+2 added
1 from __future__ import annotations2 3 from enum import IntEnum4 5+__all__ = ["codes"]6 7+8 class codes(IntEnum):9 """HTTP status codes and reason phrases10 11 Status codes from the following RFCs are all observed:151 unmodified linesmodified:httpx/_types.py+2 added
106 unmodified lines107 RequestFiles = Union[Mapping[str, FileTypes], Sequence[Tuple[str, FileTypes]]]108 109 RequestExtensions = MutableMapping[str, Any]110 111+__all__ = ["AsyncByteStream", "SyncByteStream"]112 113+114 class SyncByteStream:115 def __iter__(self) -> Iterator[bytes]:116 raise NotImplementedError(117 "The '__iter__' method must be implemented."19 unmodified linesmodified:httpx/_urls.py+2 added
7 unmodified lines8 from ._types import QueryParamTypes, RawURL, URLTypes9 from ._urlparse import urlencode, urlparse10 from ._utils import primitive_value_to_str11 12+__all__ = ["URL", "QueryParams"]13 14+15 class URL:16 """17 url = httpx.URL("HTTPS://jo%40email.com:a%20secret@müller.de:1234/pa%20th?search=ab#anchorlink")18 630 unmodified linesmodified:pyproject.toml+3 added
99 unmodified lines100 101 [tool.ruff.isort]102 combine-as-imports = true103 104+[tool.ruff.lint.per-file-ignores]105+"__init__.py" = ["F403", "F405"]106+107 [tool.mypy]108 ignore_missing_imports = true109 strict = true110 21 unmodified lines