parse_options_header = None
+if typing.TYPE_CHECKING:
+ from starlette.routing import Router
+
+
SERVER_PUSH_HEADERS_TO_COPY = {
"accept",
"accept-encoding",
return self._state
def url_for(self, name: str, **path_params: typing.Any) -> str:
- router = self.scope["router"]
+ router: Router = self.scope["router"]
url_path = router.url_path_for(name, **path_params)
return url_path.make_absolute_url(base_url=self.base_url)
def matches(self, scope: Scope) -> typing.Tuple[Match, Scope]:
raise NotImplementedError() # pragma: no cover
- def url_path_for(self, name: str, **path_params: str) -> URLPath:
+ def url_path_for(self, name: str, **path_params: typing.Any) -> URLPath:
raise NotImplementedError() # pragma: no cover
async def handle(self, scope: Scope, receive: Receive, send: Send) -> None:
return Match.FULL, child_scope
return Match.NONE, {}
- def url_path_for(self, name: str, **path_params: str) -> URLPath:
+ def url_path_for(self, name: str, **path_params: typing.Any) -> URLPath:
seen_params = set(path_params.keys())
expected_params = set(self.param_convertors.keys())
return Match.FULL, child_scope
return Match.NONE, {}
- def url_path_for(self, name: str, **path_params: str) -> URLPath:
+ def url_path_for(self, name: str, **path_params: typing.Any) -> URLPath:
seen_params = set(path_params.keys())
expected_params = set(self.param_convertors.keys())
return Match.FULL, child_scope
return Match.NONE, {}
- def url_path_for(self, name: str, **path_params: str) -> URLPath:
+ def url_path_for(self, name: str, **path_params: typing.Any) -> URLPath:
if self.name is not None and name == self.name and "path" in path_params:
# 'name' matches "<mount_name>".
path_params["path"] = path_params["path"].lstrip("/")
return Match.FULL, child_scope
return Match.NONE, {}
- def url_path_for(self, name: str, **path_params: str) -> URLPath:
+ def url_path_for(self, name: str, **path_params: typing.Any) -> URLPath:
if self.name is not None and name == self.name and "path" in path_params:
# 'name' matches "<mount_name>".
path = path_params.pop("path")
response = PlainTextResponse("Not Found", status_code=404)
await response(scope, receive, send)
- def url_path_for(self, name: str, **path_params: str) -> URLPath:
+ def url_path_for(self, name: str, **path_params: typing.Any) -> URLPath:
for route in self.routes:
try:
return route.url_path_for(name, **path_params)