MCPcopy
hub / github.com/encode/starlette / replace

Method replace

starlette/datastructures.py:115–141  ·  view source on GitHub ↗
(self, **kwargs: Any)

Source from the content-addressed store, hash-verified

113 return self.scheme in ("https", "wss")
114
115 def replace(self, **kwargs: Any) -> URL:
116 if "username" in kwargs or "password" in kwargs or "hostname" in kwargs or "port" in kwargs:
117 hostname = kwargs.pop("hostname", None)
118 port = kwargs.pop("port", self.port)
119 username = kwargs.pop("username", self.username)
120 password = kwargs.pop("password", self.password)
121
122 if hostname is None:
123 netloc = self.netloc
124 _, _, hostname = netloc.rpartition("@")
125
126 if hostname and hostname[-1] != "]":
127 hostname = hostname.rsplit(":", 1)[0]
128
129 netloc = hostname
130 if port is not None:
131 netloc += f":{port}"
132 if username is not None:
133 userpass = username
134 if password is not None:
135 userpass += f":{password}"
136 netloc = f"{userpass}@{netloc}"
137
138 kwargs["netloc"] = netloc
139
140 components = self.components._replace(**kwargs)
141 return self.__class__(components.geturl())
142
143 def include_query_params(self, **kwargs: Any) -> URL:
144 params = MultiDict(parse_qsl(self.query, keep_blank_values=True))

Callers 12

get_responseMethod · 0.95
include_query_paramsMethod · 0.95
replace_query_paramsMethod · 0.95
remove_query_paramsMethod · 0.95
__repr__Method · 0.95
__call__Method · 0.95
__call__Method · 0.95
test_urlFunction · 0.95
replace_paramsFunction · 0.80
__init__Method · 0.80
format_lineMethod · 0.80
build_environFunction · 0.80

Calls 1

popMethod · 0.45

Tested by 1

test_urlFunction · 0.76