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

Deprecate custom router #3021

Merged
merged 3 commits into from
May 24, 2018
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/3021.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate custom application's router.
3 changes: 3 additions & 0 deletions aiohttp/web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def __init__(self, *,
debug=...):
if router is None:
router = UrlDispatcher()
else:
warnings.warn("router argument is deprecated", DeprecationWarning,
stacklevel=2)
assert isinstance(router, AbstractRouter), router

if loop is not None:
Expand Down
5 changes: 5 additions & 0 deletions docs/web_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,11 @@ duplicated like one using :meth:`Application.copy`.
creates :class:`UrlDispatcher` by default if
*router* is ``None``.

.. deprecated:: 3.3

The custom routers support is deprecated, the parameter will
be removed in 4.0.

:param middlewares: :class:`list` of middleware factories, see
:ref:`aiohttp-web-middlewares` for details.

Expand Down
3 changes: 2 additions & 1 deletion tests/test_web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ async def cb(app):

def test_non_default_router():
router = mock.Mock(spec=AbstractRouter)
app = web.Application(router=router)
with pytest.warns(DeprecationWarning):
app = web.Application(router=router)
assert router is app.router


Expand Down
3 changes: 2 additions & 1 deletion tests/test_web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ class MyRouter(abc.AbstractRouter):
async def resolve(self, request):
raise web.HTTPPreconditionFailed()

app = web.Application(router=MyRouter())
with pytest.warns(DeprecationWarning):
app = web.Application(router=MyRouter())

client = await aiohttp_client(app)

Expand Down