Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace AbstractMatchInfo with UrlMappingMatchInfo. #6135

Merged
merged 18 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/4748.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change return type on URLDispatcher to UrlMappingMatchInfo to improve type annotations.
2 changes: 1 addition & 1 deletion aiohttp/web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ async def _handle(self, request: Request) -> StreamResponse:
match_info.freeze()

resp = None
request._match_info = match_info # type: ignore[assignment]
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 @@ -23,7 +23,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[assignment]
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 @@ -82,7 +82,7 @@


_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 @@ -982,7 +982,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 @@ -992,11 +992,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
1 change: 0 additions & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-r base.txt
Brotli==1.0.9
coverage==6.0.2
Expand Down