@@ -144,7 +144,7 @@ def copy_remove(self, key: str) -> "Headers":
144144 h = {k : v for k , v in self ._dict .items () if k .lower () != key .lower ()}
145145 return Headers (h )
146146
147- def copy_update (self , update : typing .Mapping [str , str ] | typing . Sequence [ tuple [ str , str ]] ) -> "Headers" :
147+ def copy_update (self , update : "Headers" | typing .Mapping [str , str ] | None ) -> "Headers" :
148148 """
149149 Return a new Headers instance, removing the value of a key.
150150
@@ -154,7 +154,10 @@ def copy_update(self, update: typing.Mapping[str, str] | typing.Sequence[tuple[s
154154 h = h.copy_update({"Accept-Encoding": "gzip"})
155155 assert h == httpx.Headers({"Accept": "*/*", "Accept-Encoding": "gzip", "User-Agent": "python/httpx"})
156156 """
157- new = Headers (update )
157+ if update is None :
158+ return self
159+
160+ new = update if isinstance (update , Headers ) else Headers (update )
158161
159162 # Remove updated items using a case-insensitive approach...
160163 keys = set ([key .lower () for key in new .keys ()])
@@ -172,7 +175,7 @@ def __getitem__(self, key: str) -> str:
172175 return v
173176 raise KeyError (key )
174177
175- def __contains__ (self , key : object ) -> bool :
178+ def __contains__ (self , key : typing . Any ) -> bool :
176179 match = key .lower ()
177180 return any (k .lower () == match for k in self ._dict .keys ())
178181
@@ -185,7 +188,7 @@ def __len__(self) -> int:
185188 def __bool__ (self ) -> bool :
186189 return bool (self ._dict )
187190
188- def __eq__ (self , other : object ) -> bool :
191+ def __eq__ (self , other : typing . Any ) -> bool :
189192 self_lower = {k .lower (): v for k , v in self .items ()}
190193 other_lower = {k .lower (): v for k , v in Headers (other ).items ()}
191194 return self_lower == other_lower
0 commit comments