mirror of https://github.com/encode/starlette.git
replace -> replace_components (Avoid clashing with str builtin)
This commit is contained in:
parent
7eafe567df
commit
6d2e9f4fae
|
@ -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())
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue