]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Define and expose the API from the same place (#3106)
authorKar Petrosyan <92274156+karpetrosyan@users.noreply.github.com>
Fri, 23 Feb 2024 12:30:05 +0000 (16:30 +0400)
committerGitHub <noreply@github.com>
Fri, 23 Feb 2024 12:30:05 +0000 (12:30 +0000)
* Tidy up imports

* Update tests/test_exported_members.py

---------

Co-authored-by: Tom Christie <tom@tomchristie.com>
18 files changed:
httpx/__init__.py
httpx/_api.py
httpx/_auth.py
httpx/_client.py
httpx/_config.py
httpx/_content.py
httpx/_exceptions.py
httpx/_models.py
httpx/_status_codes.py
httpx/_transports/__init__.py
httpx/_transports/asgi.py
httpx/_transports/base.py
httpx/_transports/default.py
httpx/_transports/mock.py
httpx/_transports/wsgi.py
httpx/_types.py
httpx/_urls.py
pyproject.toml

index f61112f8b20e11be3395d6f9265082ad762a7638..e9addde071f81758baf350c4ab6bde2556340131 100644 (file)
@@ -1,48 +1,15 @@
 from .__version__ import __description__, __title__, __version__
-from ._api import delete, get, head, options, patch, post, put, request, stream
-from ._auth import Auth, BasicAuth, DigestAuth, NetRCAuth
-from ._client import USE_CLIENT_DEFAULT, AsyncClient, Client
-from ._config import Limits, Proxy, Timeout, create_ssl_context
-from ._content import ByteStream
-from ._exceptions import (
-    CloseError,
-    ConnectError,
-    ConnectTimeout,
-    CookieConflict,
-    DecodingError,
-    HTTPError,
-    HTTPStatusError,
-    InvalidURL,
-    LocalProtocolError,
-    NetworkError,
-    PoolTimeout,
-    ProtocolError,
-    ProxyError,
-    ReadError,
-    ReadTimeout,
-    RemoteProtocolError,
-    RequestError,
-    RequestNotRead,
-    ResponseNotRead,
-    StreamClosed,
-    StreamConsumed,
-    StreamError,
-    TimeoutException,
-    TooManyRedirects,
-    TransportError,
-    UnsupportedProtocol,
-    WriteError,
-    WriteTimeout,
-)
-from ._models import Cookies, Headers, Request, Response
-from ._status_codes import codes
-from ._transports.asgi import ASGITransport
-from ._transports.base import AsyncBaseTransport, BaseTransport
-from ._transports.default import AsyncHTTPTransport, HTTPTransport
-from ._transports.mock import MockTransport
-from ._transports.wsgi import WSGITransport
-from ._types import AsyncByteStream, SyncByteStream
-from ._urls import URL, QueryParams
+from ._api import *
+from ._auth import *
+from ._client import *
+from ._config import *
+from ._content import *
+from ._exceptions import *
+from ._models import *
+from ._status_codes import *
+from ._transports import *
+from ._types import *
+from ._urls import *
 
 try:
     from ._main import main
index b5821cc49e6cc48e1f2c2711fb2ef5ae18f68b78..3dd943b3788b03d34967827940d4a816c3c4f0f3 100644 (file)
@@ -22,6 +22,18 @@ from ._types import (
     VerifyTypes,
 )
 
+__all__ = [
+    "delete",
+    "get",
+    "head",
+    "options",
+    "patch",
+    "post",
+    "put",
+    "request",
+    "stream",
+]
+
 
 def request(
     method: str,
index 903e39961740940faf79872da9347f3bf9624983..b03971ab4b311d60790dc22ca24d9966426ec0a4 100644 (file)
@@ -16,6 +16,9 @@ if typing.TYPE_CHECKING:  # pragma: no cover
     from hashlib import _Hash
 
 
+__all__ = ["Auth", "BasicAuth", "DigestAuth", "NetRCAuth"]
+
+
 class Auth:
     """
     Base class for all authentication schemes.
index e2c6702e0c7ecb0d9e12ae41d19a156daaed6981..cf3b30626da4b113f6189ba6d16f3a3b672b1c3b 100644 (file)
@@ -58,6 +58,8 @@ from ._utils import (
     same_origin,
 )
 
+__all__ = ["USE_CLIENT_DEFAULT", "AsyncClient", "Client"]
+
 # The type annotation for @classmethod and context managers here follows PEP 484
 # https://www.python.org/dev/peps/pep-0484/#annotating-instance-and-class-methods
 T = typing.TypeVar("T", bound="Client")
index 7636a5dcc5802ff44ca02a0bd0b1fcb51c0bc2c0..6662ea806733833e81c94a3c3b86f59ddb4f209d 100644 (file)
@@ -14,6 +14,8 @@ from ._types import CertTypes, HeaderTypes, TimeoutTypes, URLTypes, VerifyTypes
 from ._urls import URL
 from ._utils import get_ca_bundle_from_env
 
+__all__ = ["Limits", "Proxy", "Timeout", "create_ssl_context"]
+
 DEFAULT_CIPHERS = ":".join(
     [
         "ECDHE+AESGCM",
index 10b574bb3d7d8dfc62057407426d4b2a962c300c..786699f38fff25f03dc00b3b7c97e3e7d4d1a878 100644 (file)
@@ -25,6 +25,8 @@ from ._types import (
 )
 from ._utils import peek_filelike_length, primitive_value_to_str
 
+__all__ = ["ByteStream"]
+
 
 class ByteStream(AsyncByteStream, SyncByteStream):
     def __init__(self, stream: bytes) -> None:
index 11424621c044057c849a950c6b3bfdfb0f2801fe..18dfa2f2b72b2d8ea8dae7a79247e0db133d2b30 100644 (file)
@@ -38,6 +38,37 @@ import typing
 if typing.TYPE_CHECKING:
     from ._models import Request, Response  # pragma: no cover
 
+__all__ = [
+    "CloseError",
+    "ConnectError",
+    "ConnectTimeout",
+    "CookieConflict",
+    "DecodingError",
+    "HTTPError",
+    "HTTPStatusError",
+    "InvalidURL",
+    "LocalProtocolError",
+    "NetworkError",
+    "PoolTimeout",
+    "ProtocolError",
+    "ProxyError",
+    "ReadError",
+    "ReadTimeout",
+    "RemoteProtocolError",
+    "RequestError",
+    "RequestNotRead",
+    "ResponseNotRead",
+    "StreamClosed",
+    "StreamConsumed",
+    "StreamError",
+    "TimeoutException",
+    "TooManyRedirects",
+    "TransportError",
+    "UnsupportedProtocol",
+    "WriteError",
+    "WriteTimeout",
+]
+
 
 class HTTPError(Exception):
     """
index cd76705f1ab17a92052b8af55c56b7a1a33d9922..92b393a233fbacc4f5499ed31658010a9b40500a 100644 (file)
@@ -53,6 +53,8 @@ from ._utils import (
     parse_header_links,
 )
 
+__all__ = ["Cookies", "Headers", "Request", "Response"]
+
 
 class Headers(typing.MutableMapping[str, str]):
     """
index 4cde4e6845c4528cfda25a54cffcca5c8cd2858a..133a6231a5b53fd2f073799ca1bd07c50abe40ae 100644 (file)
@@ -2,6 +2,8 @@ from __future__ import annotations
 
 from enum import IntEnum
 
+__all__ = ["codes"]
+
 
 class codes(IntEnum):
     """HTTP status codes and reason phrases
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7a321053b29bcd48698cf2bd74a1d19c8556aefb 100644 (file)
@@ -0,0 +1,15 @@
+from .asgi import *
+from .base import *
+from .default import *
+from .mock import *
+from .wsgi import *
+
+__all__ = [
+    "ASGITransport",
+    "AsyncBaseTransport",
+    "BaseTransport",
+    "AsyncHTTPTransport",
+    "HTTPTransport",
+    "MockTransport",
+    "WSGITransport",
+]
index 9543a12861cf7f792e93aa839fb81112e6f9b031..794cb17bc8c116f6abe76730a2ef3c26e7896e0e 100644 (file)
@@ -25,6 +25,8 @@ _ASGIApp = typing.Callable[
     [typing.Dict[str, typing.Any], _Receive, _Send], typing.Coroutine[None, None, None]
 ]
 
+__all__ = ["ASGITransport"]
+
 
 def create_event() -> Event:
     if sniffio.current_async_library() == "trio":
index 8b6dc3c239151fa80fdc7b9605a63fa7f4915c61..66fd99d702480b555c06694fe14715ea6df3dfc3 100644 (file)
@@ -8,6 +8,8 @@ from .._models import Request, Response
 T = typing.TypeVar("T", bound="BaseTransport")
 A = typing.TypeVar("A", bound="AsyncBaseTransport")
 
+__all__ = ["AsyncBaseTransport", "BaseTransport"]
+
 
 class BaseTransport:
     def __enter__(self: T) -> T:
index 14476a3ce3effdfa76bec5d47062a1f6242dc8bb..e82104e9d62c55309a7cd0d3346ff923a39189d9 100644 (file)
@@ -62,6 +62,8 @@ SOCKET_OPTION = typing.Union[
     typing.Tuple[int, int, None, int],
 ]
 
+__all__ = ["AsyncHTTPTransport", "HTTPTransport"]
+
 
 @contextlib.contextmanager
 def map_httpcore_exceptions() -> typing.Iterator[None]:
index 5abea837312b22f502ef18675e1a1f7b2b84a1dc..8c418f59e06cae43abdbb626ec21cafc7e8c6277 100644 (file)
@@ -9,6 +9,9 @@ SyncHandler = typing.Callable[[Request], Response]
 AsyncHandler = typing.Callable[[Request], typing.Coroutine[None, None, Response]]
 
 
+__all__ = ["MockTransport"]
+
+
 class MockTransport(AsyncBaseTransport, BaseTransport):
     def __init__(self, handler: SyncHandler | AsyncHandler) -> None:
         self.handler = handler
index cd03a9417baf8148369e9dc7e2809595ecdee47b..8592ffe017a87367cc7578184540096a9682908d 100644 (file)
@@ -16,6 +16,9 @@ if typing.TYPE_CHECKING:
 _T = typing.TypeVar("_T")
 
 
+__all__ = ["WSGITransport"]
+
+
 def _skip_leading_empty_chunks(body: typing.Iterable[_T]) -> typing.Iterable[_T]:
     body = iter(body)
     for chunk in body:
index 649d101d54a232a05bbdc16f2f44cb4882118667..b7b0518c3594d05d7944cdf0ac766142cfab90fc 100644 (file)
@@ -108,6 +108,8 @@ RequestFiles = Union[Mapping[str, FileTypes], Sequence[Tuple[str, FileTypes]]]
 
 RequestExtensions = MutableMapping[str, Any]
 
+__all__ = ["AsyncByteStream", "SyncByteStream"]
+
 
 class SyncByteStream:
     def __iter__(self) -> Iterator[bytes]:
index 43dedd5644c6aef93004f0e2c82bd2576792109b..f9f68a9955e1ca12c205835c061886dd68405e21 100644 (file)
@@ -9,6 +9,8 @@ from ._types import QueryParamTypes, RawURL, URLTypes
 from ._urlparse import urlencode, urlparse
 from ._utils import primitive_value_to_str
 
+__all__ = ["URL", "QueryParams"]
+
 
 class URL:
     """
index 4f7a848f8350ae392979d173631f27db6c6f7fd5..3fe24a14d63334daec57d32018f390542f2536da 100644 (file)
@@ -101,6 +101,9 @@ ignore = ["B904", "B028"]
 [tool.ruff.isort]
 combine-as-imports = true
 
+[tool.ruff.lint.per-file-ignores]
+"__init__.py" = ["F403", "F405"]
+
 [tool.mypy]
 ignore_missing_imports = true
 strict = true