replace -> replace_components (Avoid clashing with str builtin)

This commit is contained in:
Tom Christie 2018-10-02 13:13:16 +01:00
parent 7eafe567df
commit 6d2e9f4fae
2 changed files with 2 additions and 2 deletions

View File

@ -49,7 +49,7 @@ class URL(str):
def port(self) -> typing.Optional[int]: def port(self) -> typing.Optional[int]:
return self.components.port 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) components = self.components._replace(**kwargs)
return URL(components.geturl()) return URL(components.geturl())

View File

@ -13,7 +13,7 @@ def test_url():
assert u.query == "abc=123" assert u.query == "abc=123"
assert u.params == "" assert u.params == ""
assert u.fragment == "anchor" 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 == "http://example.org:123/path/to/somewhere?abc=123#anchor"
assert new.scheme == "http" assert new.scheme == "http"