Skip to content

Commit

Permalink
Deprecate bare aiohttp.request(), aiohttp.get() and family
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jan 13, 2016
1 parent 95107c6 commit e8b47f7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ CHANGES
- Deprecate Application.finish() / Application.register_on_finish() in favor of
on_cleanup.

- Get rid of bare aiohttp.request(), aiohttp.get() and family #729
- Get rid of bare aiohttp.request(), aiohttp.get() and family in docs #729

- Deprecate bare aiohttp.request(), aiohttp.get() and family #729


10 changes: 10 additions & 0 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ def request(method, url, *,
>>> data = yield from resp.read()
"""
warnings.warn("Use ClientSession().request() instead", DeprecationWarning)
if connector is None:
connector = aiohttp.TCPConnector(loop=loop, force_close=True)

Expand Down Expand Up @@ -663,37 +664,46 @@ def request(method, url, *,


def get(url, **kwargs):
warnings.warn("Use ClientSession().get() instead", DeprecationWarning)
return request(hdrs.METH_GET, url, **kwargs)


def options(url, **kwargs):
warnings.warn("Use ClientSession().options() instead", DeprecationWarning)
return request(hdrs.METH_OPTIONS, url, **kwargs)


def head(url, **kwargs):
warnings.warn("Use ClientSession().head() instead", DeprecationWarning)
return request(hdrs.METH_HEAD, url, **kwargs)


def post(url, **kwargs):
warnings.warn("Use ClientSession().post() instead", DeprecationWarning)
return request(hdrs.METH_POST, url, **kwargs)


def put(url, **kwargs):
warnings.warn("Use ClientSession().put() instead", DeprecationWarning)
return request(hdrs.METH_PUT, url, **kwargs)


def patch(url, **kwargs):
warnings.warn("Use ClientSession().patch() instead", DeprecationWarning)
return request(hdrs.METH_PATCH, url, **kwargs)


def delete(url, **kwargs):
warnings.warn("Use ClientSession().delete() instead", DeprecationWarning)
return request(hdrs.METH_DELETE, url, **kwargs)


def ws_connect(url, *, protocols=(), timeout=10.0, connector=None, auth=None,
ws_response_class=ClientWebSocketResponse, autoclose=True,
autoping=True, loop=None, origin=None, headers=None):

warnings.warn("Use ClientSession().ws_connect() instead",
DeprecationWarning)
if loop is None:
loop = asyncio.get_event_loop()

Expand Down
36 changes: 36 additions & 0 deletions docs/client_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ Usage::
assert resp.status == 200
print(await resp.text())

.. deprecated:: 0.21

Use :meth:`ClientSession.request`.


.. coroutinefunction:: get(url, **kwargs)

Expand All @@ -455,6 +459,10 @@ Usage::

:return: :class:`ClientResponse` or derived from

.. deprecated:: 0.21

Use :meth:`ClientSession.get`.


.. coroutinefunction:: options(url, **kwargs)

Expand All @@ -466,6 +474,10 @@ Usage::

:return: :class:`ClientResponse` or derived from

.. deprecated:: 0.21

Use :meth:`ClientSession.options`.


.. coroutinefunction:: head(url, **kwargs)

Expand All @@ -477,6 +489,10 @@ Usage::

:return: :class:`ClientResponse` or derived from

.. deprecated:: 0.21

Use :meth:`ClientSession.head`.


.. coroutinefunction:: delete(url, **kwargs)

Expand All @@ -488,6 +504,10 @@ Usage::

:return: :class:`ClientResponse` or derived from

.. deprecated:: 0.21

Use :meth:`ClientSession.delete`.


.. coroutinefunction:: post(url, *, data=None, **kwargs)

Expand All @@ -499,6 +519,10 @@ Usage::

:return: :class:`ClientResponse` or derived from

.. deprecated:: 0.21

Use :meth:`ClientSession.post`.


.. coroutinefunction:: put(url, *, data=None, **kwargs)

Expand All @@ -510,6 +534,10 @@ Usage::

:return: :class:`ClientResponse` or derived from

.. deprecated:: 0.21

Use :meth:`ClientSession.put`.


.. coroutinefunction:: patch(url, *, data=None, **kwargs)

Expand All @@ -521,6 +549,10 @@ Usage::

:return: :class:`ClientResponse` or derived from

.. deprecated:: 0.21

Use :meth:`ClientSession.patch`.


.. coroutinefunction:: ws_connect(url, *, protocols=(), \
timeout=10.0, connector=None, auth=None,\
Expand Down Expand Up @@ -580,6 +612,10 @@ Usage::

Add *headers* parameter.

.. deprecated:: 0.21

Use :meth:`ClientSession.ws_connect`.


.. _aiohttp-client-reference-connectors:

Expand Down

0 comments on commit e8b47f7

Please sign in to comment.