File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
tests/unit/test_datastructures Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ def with_replacements(
200200 scheme : str = "" ,
201201 netloc : str = "" ,
202202 path : str = "" ,
203- query : str | MultiDict | None = None ,
203+ query : str | MultiDict | None | EmptyType = Empty ,
204204 fragment : str = "" ,
205205 ) -> URL :
206206 """Create a new URL, replacing the given components.
@@ -217,12 +217,13 @@ def with_replacements(
217217 """
218218 if isinstance (query , MultiDict ):
219219 query = urlencode (query = query )
220+ query = (query if query is not Empty else self .query ) or ""
220221
221222 return URL .from_components ( # type: ignore[no-any-return]
222223 scheme = scheme or self .scheme ,
223224 netloc = netloc or self .netloc ,
224225 path = path or self .path ,
225- query = query or self . query ,
226+ query = query ,
226227 fragment = fragment or self .fragment ,
227228 )
228229
Original file line number Diff line number Diff line change @@ -60,6 +60,9 @@ def test_url_from_components(component: str, value: str) -> None:
6060 ("scheme" , "http" , "http" ),
6161 ("netloc" , "example.com" , "example.com" ),
6262 ("path" , "/foo" , "/foo" ),
63+ ("query" , None , "" ),
64+ ("query" , "" , "" ),
65+ ("query" , MultiDict ({}), "" ),
6366 ("query" , "foo=baz" , "foo=baz" ),
6467 ("query" , MultiDict ({"foo" : "baz" }), "foo=baz" ),
6568 ("fragment" , "anchor2" , "anchor2" ),
You can’t perform that action at this time.
0 commit comments