]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Black formatting 16/head
authorTom Christie <tom@tomchristie.com>
Tue, 10 Jul 2018 14:30:54 +0000 (15:30 +0100)
committerTom Christie <tom@tomchristie.com>
Tue, 10 Jul 2018 14:30:54 +0000 (15:30 +0100)
starlette/__init__.py
starlette/datastructures.py
starlette/response.py
starlette/testclient.py

index 1c2288c0c5a48be17f53af2c91d51c1650f7fd4e..22ae9352188f8533423ceebe6dac705621579b30 100644 (file)
@@ -1,5 +1,11 @@
 from starlette.decorators import asgi_application
-from starlette.response import HTMLResponse, JSONResponse, Response, PlainTextResponse, StreamingResponse
+from starlette.response import (
+    HTMLResponse,
+    JSONResponse,
+    Response,
+    PlainTextResponse,
+    StreamingResponse,
+)
 from starlette.request import Request
 from starlette.routing import Path, PathPrefix, Router
 from starlette.testclient import TestClient
index ae3fb37edef569e6eef9b3e63c196caea11eff95..cfb24bf923e8468fe26994b2a20b99e8e57dca12 100644 (file)
@@ -131,14 +131,14 @@ class Headers(typing.Mapping[str, str]):
             self._list = value
 
     def keys(self):
-        return [key.decode('latin-1') for key, value in self._list]
+        return [key.decode("latin-1") for key, value in self._list]
 
     def values(self):
-        return [value.decode('latin-1') for key, value in self._list]
+        return [value.decode("latin-1") for key, value in self._list]
 
     def items(self):
         return [
-            (key.decode('latin-1'), value.decode('latin-1'))
+            (key.decode("latin-1"), value.decode("latin-1"))
             for key, value in self._list
         ]
 
@@ -149,17 +149,18 @@ class Headers(typing.Mapping[str, str]):
             return default
 
     def get_list(self, key: str) -> typing.List[str]:
-        get_header_key = key.lower().encode('latin-1')
+        get_header_key = key.lower().encode("latin-1")
         return [
-            item_value.decode('latin-1') for item_key, item_value in self._list
+            item_value.decode("latin-1")
+            for item_key, item_value in self._list
             if item_key == get_header_key
         ]
 
     def __getitem__(self, key: str):
-        get_header_key = key.lower().encode('latin-1')
+        get_header_key = key.lower().encode("latin-1")
         for header_key, header_value in self._list:
             if header_key == get_header_key:
-                return header_value.decode('latin-1')
+                return header_value.decode("latin-1")
         raise KeyError(key)
 
     def __contains__(self, key: str):
@@ -182,8 +183,8 @@ class Headers(typing.Mapping[str, str]):
 
 class MutableHeaders(Headers):
     def __setitem__(self, key: str, value: str):
-        set_key = key.lower().encode('latin-1')
-        set_value = value.encode('latin-1')
+        set_key = key.lower().encode("latin-1")
+        set_value = value.encode("latin-1")
 
         pop_indexes = []
         for idx, (item_key, item_value) in enumerate(self._list):
index 18f5aea7dde6964041d889950f19d6606937ff05..28d0efd8bff2f916bb779ab412d65e1c56362f14 100644 (file)
@@ -13,7 +13,7 @@ class Response:
         content: typing.Any,
         status_code: int = 200,
         headers: dict = None,
-        media_type: str = None
+        media_type: str = None,
     ) -> None:
         self.body = self.render(content)
         self.status_code = status_code
@@ -33,7 +33,7 @@ class Response:
             missing_content_type = True
         else:
             raw_headers = [
-                (k.lower().encode('latin-1'), v.encode('latin-1'))
+                (k.lower().encode("latin-1"), v.encode("latin-1"))
                 for k, v in headers.items()
             ]
             missing_content_length = "content-length" not in headers
@@ -47,14 +47,14 @@ class Response:
             content_type = self.media_type
             if content_type.startswith("text/") and self.charset is not None:
                 content_type += "; charset=%s" % self.charset
-            content_type_value = content_type.encode('latin-1')
+            content_type_value = content_type.encode("latin-1")
             raw_headers.append((b"content-type", content_type_value))
 
         self.raw_headers = raw_headers
 
     @property
     def headers(self):
-        if not hasattr(self, '_headers'):
+        if not hasattr(self, "_headers"):
             self._headers = MutableHeaders(self.raw_headers)
         return self._headers
 
@@ -96,7 +96,7 @@ class StreamingResponse(Response):
         content: typing.Any,
         status_code: int = 200,
         headers: dict = None,
-        media_type: str = None
+        media_type: str = None,
     ) -> None:
         self.body_iterator = content
         self.status_code = status_code
@@ -126,7 +126,7 @@ class StreamingResponse(Response):
             missing_content_type = True
         else:
             raw_headers = [
-                (k.lower().encode('latin-1'), v.encode('latin-1'))
+                (k.lower().encode("latin-1"), v.encode("latin-1"))
                 for k, v in headers.items()
             ]
             missing_content_type = "content-type" not in headers
@@ -135,7 +135,7 @@ class StreamingResponse(Response):
             content_type = self.media_type
             if content_type.startswith("text/") and self.charset is not None:
                 content_type += "; charset=%s" % self.charset
-            content_type_value = content_type.encode('latin-1')
+            content_type_value = content_type.encode("latin-1")
             raw_headers.append((b"content-type", content_type_value))
 
         self.raw_headers = raw_headers
index ac1631250284d59b5c67a3e3c838e8768f172b8e..1073d36560793df15267f163b36726a3d0a9d714 100644 (file)
@@ -48,7 +48,8 @@ class _ASGIAdapter(requests.adapters.HTTPAdapter):
 
         # Include other request headers.
         headers += [
-            [key.lower().encode(), value.encode()] for key, value in request.headers.items()
+            [key.lower().encode(), value.encode()]
+            for key, value in request.headers.items()
         ]
 
         scope = {