]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Touch up types in MutableHeaders (#1920)
authorAdrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Fri, 21 Oct 2022 13:22:30 +0000 (08:22 -0500)
committerGitHub <noreply@github.com>
Fri, 21 Oct 2022 13:22:30 +0000 (08:22 -0500)
starlette/datastructures.py

index 096ad21021eb321688e35c71e845b2f2746aa90b..ebef2ebdfa5881cc10ee1b17b79ac3aedc924b51 100644 (file)
@@ -595,7 +595,7 @@ class MutableHeaders(Headers):
         set_key = key.lower().encode("latin-1")
         set_value = value.encode("latin-1")
 
-        found_indexes = []
+        found_indexes: "typing.List[int]" = []
         for idx, (item_key, item_value) in enumerate(self._list):
             if item_key == set_key:
                 found_indexes.append(idx)
@@ -615,7 +615,7 @@ class MutableHeaders(Headers):
         """
         del_key = key.lower().encode("latin-1")
 
-        pop_indexes = []
+        pop_indexes: "typing.List[int]" = []
         for idx, (item_key, item_value) in enumerate(self._list):
             if item_key == del_key:
                 pop_indexes.append(idx)
@@ -623,13 +623,13 @@ class MutableHeaders(Headers):
         for idx in reversed(pop_indexes):
             del self._list[idx]
 
-    def __ior__(self, other: typing.Mapping) -> "MutableHeaders":
+    def __ior__(self, other: typing.Mapping[str, str]) -> "MutableHeaders":
         if not isinstance(other, typing.Mapping):
             raise TypeError(f"Expected a mapping but got {other.__class__.__name__}")
         self.update(other)
         return self
 
-    def __or__(self, other: typing.Mapping) -> "MutableHeaders":
+    def __or__(self, other: typing.Mapping[str, str]) -> "MutableHeaders":
         if not isinstance(other, typing.Mapping):
             raise TypeError(f"Expected a mapping but got {other.__class__.__name__}")
         new = self.mutablecopy()
@@ -654,7 +654,7 @@ class MutableHeaders(Headers):
         self._list.append((set_key, set_value))
         return value
 
-    def update(self, other: typing.Mapping) -> None:
+    def update(self, other: typing.Mapping[str, str]) -> None:
         for key, val in other.items():
             self[key] = val