Skip to content

Commit

Permalink
bind to object
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Nov 27, 2023
1 parent 13cc627 commit 01c9353
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions aiohttp/web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,9 +974,6 @@ def __contains__(self, route: object) -> bool:
return route in self._routes


NOT_FOUND_MATCH_ERROR = MatchInfoError(HTTPNotFound())


class UrlDispatcher(AbstractRouter, Mapping[str, AbstractResource]):
NAME_SPLIT_RE = re.compile(r"[.:-]")

Expand All @@ -986,6 +983,7 @@ def __init__(self) -> None:
self._named_resources: Dict[str, AbstractResource] = {}
self._resource_index: dict[str, list[AbstractResource]] = {}
self._matched_sub_app_resources: List[MatchedSubAppResource] = []
self._http_not_found_match = MatchInfoError(HTTPNotFound())

async def resolve(self, request: Request) -> UrlMappingMatchInfo:
resource_index = self._resource_index
Expand Down Expand Up @@ -1026,7 +1024,7 @@ async def resolve(self, request: Request) -> UrlMappingMatchInfo:
if allowed_methods:
return MatchInfoError(HTTPMethodNotAllowed(request.method, allowed_methods))

return NOT_FOUND_MATCH_ERROR
return self._http_not_found_match

def __iter__(self) -> Iterator[str]:
return iter(self._named_resources)
Expand Down

0 comments on commit 01c9353

Please sign in to comment.