diff --git a/starlette/datastructures.py b/starlette/datastructures.py index 1b5e951f..02dbafa9 100644 --- a/starlette/datastructures.py +++ b/starlette/datastructures.py @@ -49,7 +49,7 @@ class URL(str): def port(self) -> typing.Optional[int]: return self.components.port - def replace(self, **kwargs: typing.Any) -> "URL": # type: ignore + def replace_components(self, **kwargs: typing.Any) -> "URL": # type: ignore components = self.components._replace(**kwargs) return URL(components.geturl()) diff --git a/tests/test_datastructures.py b/tests/test_datastructures.py index 672feaa7..58298164 100644 --- a/tests/test_datastructures.py +++ b/tests/test_datastructures.py @@ -13,7 +13,7 @@ def test_url(): assert u.query == "abc=123" assert u.params == "" assert u.fragment == "anchor" - new = u.replace(scheme="http") + new = u.replace_components(scheme="http") assert new == "http://example.org:123/path/to/somewhere?abc=123#anchor" assert new.scheme == "http"