| 113 | return self.scheme in (class="st">"https", class="st">"wss") |
| 114 | |
| 115 | def replace(self, **kwargs: Any) -> URL: |
| 116 | if class="st">"username" in kwargs or class="st">"password" in kwargs or class="st">"hostname" in kwargs or class="st">"port" in kwargs: |
| 117 | hostname = kwargs.pop(class="st">"hostname", None) |
| 118 | port = kwargs.pop(class="st">"port", self.port) |
| 119 | username = kwargs.pop(class="st">"username", self.username) |
| 120 | password = kwargs.pop(class="st">"password", self.password) |
| 121 | |
| 122 | if hostname is None: |
| 123 | netloc = self.netloc |
| 124 | _, _, hostname = netloc.rpartition(class="st">"@") |
| 125 | |
| 126 | if hostname and hostname[-1] != class="st">"]": |
| 127 | hostname = hostname.rsplit(class="st">":", 1)[0] |
| 128 | |
| 129 | netloc = hostname |
| 130 | if port is not None: |
| 131 | netloc += fclass="st">":{port}" |
| 132 | if username is not None: |
| 133 | userpass = username |
| 134 | if password is not None: |
| 135 | userpass += fclass="st">":{password}" |
| 136 | netloc = fclass="st">"{userpass}@{netloc}" |
| 137 | |
| 138 | kwargs[class="st">"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)) |