Skip to content

Commit

Permalink
Replace AbstractMatchInfo with UrlMappingMatchInfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer committed Dec 9, 2020
1 parent cb4bae7 commit d119094
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion aiohttp/web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ async def _handle(self, request: Request) -> StreamResponse:
match_info.freeze()

resp = None
request._match_info = match_info # type: ignore
request._match_info = match_info
expect = request.headers.get(hdrs.EXPECT)
if expect:
resp = await match_info.expect_handler(request)
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def _check_request_resolves(request: Request, path: str) -> Tuple[bool, Re
alt_request = request.clone(rel_url=path)

match_info = await request.app.router.resolve(alt_request)
alt_request._match_info = match_info # type: ignore
alt_request._match_info = match_info

if match_info.http_exception is None:
return True, alt_request
Expand Down
12 changes: 6 additions & 6 deletions aiohttp/web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

_WebHandler = Callable[[Request], Awaitable[StreamResponse]]
_ExpectHandler = Callable[[Request], Awaitable[None]]
_Resolve = Tuple[Optional[AbstractMatchInfo], Set[str]]
_Resolve = Tuple[Optional["UrlMappingMatchInfo"], Set[str]]


class _InfoDict(TypedDict, total=False):
Expand Down Expand Up @@ -977,7 +977,7 @@ def __init__(self) -> None:
self._resources = [] # type: List[AbstractResource]
self._named_resources = {} # type: Dict[str, AbstractResource]

async def resolve(self, request: Request) -> AbstractMatchInfo:
async def resolve(self, request: Request) -> UrlMappingMatchInfo:
method = request.method
allowed_methods = set() # type: Set[str]

Expand All @@ -987,11 +987,11 @@ async def resolve(self, request: Request) -> AbstractMatchInfo:
return match_dict
else:
allowed_methods |= allowed

if allowed_methods:
return MatchInfoError(HTTPMethodNotAllowed(method, allowed_methods))
else:
if allowed_methods:
return MatchInfoError(HTTPMethodNotAllowed(method, allowed_methods))
else:
return MatchInfoError(HTTPNotFound())
return MatchInfoError(HTTPNotFound())

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

0 comments on commit d119094

Please sign in to comment.