]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Updating docstrings
authorTom Christie <tom@tomchristie.com>
Wed, 1 May 2019 14:58:23 +0000 (15:58 +0100)
committerTom Christie <tom@tomchristie.com>
Wed, 1 May 2019 14:58:23 +0000 (15:58 +0100)
httpcore/decoders.py
httpcore/exceptions.py
httpcore/interfaces.py

index e58b8ee28c80b257910626802fcfc48fd9302114..6b11060eda54ee3ee9f81adb67e539cecf171538 100644 (file)
@@ -23,6 +23,10 @@ class Decoder:
 
 
 class IdentityDecoder(Decoder):
+    """
+    Handle unencoded data.
+    """
+
     def decode(self, data: bytes) -> bytes:
         return data
 
@@ -80,8 +84,7 @@ class BrotliDecoder(Decoder):
     """
     Handle 'brotli' decoding.
 
-    Requires `pip install brotlipy`.
-    See: https://brotlipy.readthedocs.io/
+    Requires `pip install brotlipy`. See: https://brotlipy.readthedocs.io/
     """
 
     def __init__(self) -> None:
@@ -111,7 +114,7 @@ class MultiDecoder(Decoder):
 
     def __init__(self, children: typing.Sequence[Decoder]) -> None:
         """
-        children should be a sequence of decoders in the order in which
+        'children' should be a sequence of decoders in the order in which
         each was applied.
         """
         # Note that we reverse the order for decoding.
index bae6b08df29dee744175c2af3446ec0809dc2757..55d377e0a15b4ba137f8cc01b9407805cfe73856 100644 (file)
@@ -40,6 +40,12 @@ class ProtocolError(Exception):
     """
 
 
+class DecodingError(Exception):
+    """
+    Decoding of the response failed.
+    """
+
+
 # Redirect exceptions...
 
 
@@ -68,33 +74,36 @@ class RedirectLoop(RedirectError):
     """
 
 
-# Response exceptions...
+# Stream exceptions...
+
 
+class StreamException(Exception):
+    """
+    The base class for stream exceptions.
 
-class StreamConsumed(Exception):
+    The developer made an error in accessing the request stream in
+    an invalid way.
+    """
+
+
+class StreamConsumed(StreamException):
     """
     Attempted to read or stream response content, but the content has already
     been streamed.
     """
 
 
-class ResponseNotRead(Exception):
+class ResponseNotRead(StreamException):
     """
     Attempted to access response content, without having called `read()`
     after a streaming response.
     """
 
 
-class ResponseClosed(Exception):
+class ResponseClosed(StreamException):
     """
     Attempted to read or stream response content, but the request has been
-    closed without loading the body.
-    """
-
-
-class DecodingError(Exception):
-    """
-    Decoding of the response failed.
+    closed.
     """
 
 
index 644b19119d9153e5fdfdc23fab4aa9968de1942c..2ada76c85f615b1b4b9363b216aed4c1129a81a9 100644 (file)
@@ -8,6 +8,14 @@ OptionalTimeout = typing.Optional[TimeoutConfig]
 
 
 class Adapter:
+    """
+    The base class for all adapter or dispatcher classes.
+
+    Stubs out the interface, as well as providing a `.request()` convienence
+    implementation, to make it easy to use or test stand-alone adapters,
+    without requiring a complete `Client` instance.
+    """
+
     async def request(
         self,
         method: str,
@@ -44,11 +52,23 @@ class Adapter:
 
 
 class BaseReader:
+    """
+    A stream reader. Abstracts away any asyncio-specfic interfaces
+    into a more generic base class, that we can use with alternate
+    backend, or for stand-alone test cases.
+    """
+
     async def read(self, n: int, timeout: OptionalTimeout = None) -> bytes:
         raise NotImplementedError()  # pragma: no cover
 
 
 class BaseWriter:
+    """
+    A stream writer. Abstracts away any asyncio-specfic interfaces
+    into a more generic base class, that we can use with alternate
+    backend, or for stand-alone test cases.
+    """
+
     def write_no_block(self, data: bytes) -> None:
         raise NotImplementedError()  # pragma: no cover
 
@@ -60,6 +80,12 @@ class BaseWriter:
 
 
 class BasePoolSemaphore:
+    """
+    A semaphore for use with connection pooling.
+
+    Abstracts away any asyncio-specfic interfaces.
+    """
+
     async def acquire(self) -> None:
         raise NotImplementedError()  # pragma: no cover