Skip to content

Docstring inaccurate; aiohttp.client.request #4603

Closed
@wereii

Description

🐞 Describe the bug
If you see the "Usage" part docstring of aiohttp.client.request(or also aiohttp.request) there is

...
    Usage::
      >>> import aiohttp
      >>> resp = await aiohttp.request('GET', 'http://python.org/')
      >>> resp
      <ClientResponse(python.org/) [200]>
      >>> data = await resp.read()
    """

Which as it seems isn't really reflecting of how this function should be used (ie context manager). Also see comments on issue #4065.

💡 Expected behavior

The "Usage" part of the docstring shoud probably look something like this ...

...
    Usage:
      >>> import aiohttp
      >>> async with aiohttp.request('GET', 'http://python.org/') as resp:
      ...     print(resp)
      ...     data = await resp.read()
      <ClientResponse(https://www.python.org/) [200 OK]>
    """

📋 My version of the Python

$ python3 --version
Python 3.7.5

📋 My version of the aiohttp/yarl/multidict distributions

$ python -m pip show aiohttp
Name: aiohttp
Version: 3.6.2
...
$ python -m pip show multidict
Name: multidict
Version: 4.7.5
...
$ python -m pip show yarl
Name: yarl
Version: 1.4.2
...

📋 Additional context

  • Context: client
  • Ubuntu 19.10
  • All packages from pip, no version pinning (latest avaliable?), running from virtualenv

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions