internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: aio-libs/aiohttp

Issue:
Task was destroyed but it's pending
On master, I see outputs from `run_app()` like follows:
```
======== Running on http://0.0.0.0:8080 ========
(Press CTRL+C to quit)
Task was destroyed but it is pending!
task: <Task pending name='Task-4' coro=<RequestHandler.start() done, defined at /home/andrew/.virtualenvs/multidict/lib/python3.8/site-packages/aiohttp/web_protocol.py:437> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f8822ffef10>()]>>
```
I suspect it happens on errors and keepalive closing in `web_protocol.py`.
The message should go.


Discussion:

Resolving patch:
diff --git a/aiohttp/web_protocol.py b/aiohttp/web_protocol.py
--- a/aiohttp/web_protocol.py
+++ b/aiohttp/web_protocol.py
@@ -277,6 +277,10 @@ def connection_lost(self, exc: Optional[BaseException]) -> None:
 
         if self._error_handler is not None:
             self._error_handler.cancel()
+        if self._task_handler is not None:
+            self._task_handler.cancel()
+        if self._waiter is not None:
+            self._waiter.cancel()
 
         self._task_handler = None
 


Test patch:
diff --git a/tests/test_web_protocol.py b/tests/test_web_protocol.py
--- a/tests/test_web_protocol.py
+++ b/tests/test_web_protocol.py
@@ -821,7 +821,7 @@ async def disconn():
     writer.write(b"x")
     writer.close()
     await asyncio.sleep(0.1)
-    logger.debug.assert_called_with('Ignored premature client disconnection.')
+    logger.debug.assert_called_with('Ignored premature client disconnection')
     assert disconnected_notified
Repository: aio-libs/aiohttp

Issue:
Docstring inaccurate; aiohttp.client.request
🐞 **Describe the bug**
If you see the "Usage" part docstring of [`aiohttp.client.request`(or also `aiohttp.request`)](https://github.com/aio-libs/aiohttp/blob/v4.0.0a1/aiohttp/client.py#L1068) 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**

```console
$ python3 --version
Python 3.7.5
```

📋 **My version of the aiohttp/yarl/multidict distributions**

```console
$ python -m pip show aiohttp
Name: aiohttp
Version: 3.6.2
...
```
```console
$ python -m pip show multidict
Name: multidict
Version: 4.7.5
...
```
```console
$ 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


Discussion:

Resolving patch:
diff --git a/aiohttp/client.py b/aiohttp/client.py
--- a/aiohttp/client.py
+++ b/aiohttp/client.py
@@ -1130,10 +1130,10 @@ def request(
        total timeout by default.
     Usage::
       >>> import aiohttp
-      >>> resp = await aiohttp.request('GET', 'http://python.org/')
-      >>> resp
-      <ClientResponse(python.org/) [200]>
-      >>> data = await resp.read()
+      >>> async with aiohttp.request('GET', 'http://python.org/') as resp:
+      ...    print(resp)
+      ...    data = await resp.read()
+      <ClientResponse(https://www.python.org/) [200 OK]>
     """
     connector_owner = False
     if connector is None:


Test patch:
Repository: aio-libs/aiohttp

Issue:
RouteTableDef can't register OPTIONS request handlers
🐞 **Describe the bug**
Currently it gives an AttributeError: 'RouteTableDef' object has no attribute 'options'

💡 **To Reproduce**

```py
@route.options('/path')
def opts(request):
   ...
```

💡 **Expected behavior**
It should register decorated function as the OPTIONS request handler for that path


Discussion:

Resolving patch:
diff --git a/aiohttp/web_routedef.py b/aiohttp/web_routedef.py
--- a/aiohttp/web_routedef.py
+++ b/aiohttp/web_routedef.py
@@ -191,6 +191,9 @@ def patch(self, path: str, **kwargs: Any) -> _Deco:
     def delete(self, path: str, **kwargs: Any) -> _Deco:
         return self.route(hdrs.METH_DELETE, path, **kwargs)
 
+    def options(self, path: str, **kwargs: Any) -> _Deco:
+        return self.route(hdrs.METH_OPTIONS, path, **kwargs)
+
     def view(self, path: str, **kwargs: Any) -> _Deco:
         return self.route(hdrs.METH_ANY, path, **kwargs)
 


Test patch:
diff --git a/tests/test_route_def.py b/tests/test_route_def.py
--- a/tests/test_route_def.py
+++ b/tests/test_route_def.py
@@ -232,6 +232,22 @@ async def handler(request):
     assert str(route.url_for()) == '/path'
 
 
+def test_options_deco(router) -> None:
+    routes = web.RouteTableDef()
+
+    @routes.options('/path')
+    async def handler(request):
+        pass
+
+    router.add_routes(routes)
+
+    assert len(router.routes()) == 1
+
+    route = list(router.routes())[0]
+    assert route.method == 'OPTIONS'
+    assert str(route.url_for()) == '/path'
+
+
 def test_route_deco(router) -> None:
     routes = web.RouteTableDef()
Repository: aio-libs/aiohttp

Issue:
Support multidict 5
🐣 **Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
We want to keep what we install up to date but our checks show aiohttp blocks multidict 5 (See travis on https://github.com/MirahezeBots/bots-pip-auto/pull/113)

💡 **Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->
Allow multidict 5 with aiohttp
❓ **Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
N/A

📋 **Additional context**
<!-- Add any other context or screenshots about the feature request here. -->




Discussion:
Thanks for raising the question; I just forgot to relax the dependency.
Please let me propose an alternative PR which raises the top cap; it should be backward-compatible without any issue.

@asvetlov: Multidict 5+ doesn't support python 3.5 which I think you do. That's why I chose what I did.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -53,7 +53,7 @@
 install_requires = [
     'attrs>=17.3.0',
     'chardet>=2.0,<4.0',
-    'multidict>=4.5,<6.0',
+    'multidict>=4.5',
     'async_timeout>=4.0a2,<5.0',
     'yarl>=1.0,<2.0',
     'idna-ssl>=1.0; python_version<"3.7"',


Test patch:
Repository: aio-libs/aiohttp

Issue:
Allow configuring the keepalive timeout in web.run_app
🐣 **Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
Adjusting the keepalive timeout is not possible without copy-pasting a lot of boilerplate code usually supplied by the `web.run_app` function.

💡 **Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->
Add a `keepalive_timeout` parameter to the `web.run_app` function.





Discussion:

Resolving patch:
diff --git a/aiohttp/web.py b/aiohttp/web.py
--- a/aiohttp/web.py
+++ b/aiohttp/web.py
@@ -292,6 +292,7 @@ async def _run_app(
     path: Optional[str] = None,
     sock: Optional[socket.socket] = None,
     shutdown_timeout: float = 60.0,
+    keepalive_timeout: float = 75.0,
     ssl_context: Optional[SSLContext] = None,
     print: Optional[Callable[..., None]] = print,
     backlog: int = 128,
@@ -314,6 +315,7 @@ async def _run_app(
         access_log_class=access_log_class,
         access_log_format=access_log_format,
         access_log=access_log,
+        keepalive_timeout=keepalive_timeout,
     )
 
     await runner.setup()
@@ -466,6 +468,7 @@ def run_app(
     path: Optional[str] = None,
     sock: Optional[socket.socket] = None,
     shutdown_timeout: float = 60.0,
+    keepalive_timeout: float = 75.0,
     ssl_context: Optional[SSLContext] = None,
     print: Optional[Callable[..., None]] = print,
     backlog: int = 128,
@@ -496,6 +499,7 @@ def run_app(
                 path=path,
                 sock=sock,
                 shutdown_timeout=shutdown_timeout,
+                keepalive_timeout=keepalive_timeout,
                 ssl_context=ssl_context,
                 print=print,
                 backlog=backlog,


Test patch:
diff --git a/tests/test_run_app.py b/tests/test_run_app.py
--- a/tests/test_run_app.py
+++ b/tests/test_run_app.py
@@ -16,6 +16,7 @@
 from aiohttp import web
 from aiohttp.helpers import PY_37
 from aiohttp.test_utils import make_mocked_coro
+from aiohttp.web_runner import BaseRunner
 
 # Test for features of OS' socket support
 _has_unix_domain_socks = hasattr(socket, "AF_UNIX")
@@ -824,6 +825,19 @@ async def on_startup(app):
     exc_handler.assert_called_with(patched_loop, msg)
 
 
+def test_run_app_keepalive_timeout(patched_loop, mocker, monkeypatch):
+    new_timeout = 1234
+    base_runner_init_orig = BaseRunner.__init__
+
+    def base_runner_init_spy(self, *args, **kwargs):
+        assert kwargs["keepalive_timeout"] == new_timeout
+        base_runner_init_orig(self, *args, **kwargs)
+
+    app = web.Application()
+    monkeypatch.setattr(BaseRunner, "__init__", base_runner_init_spy)
+    web.run_app(app, keepalive_timeout=new_timeout, print=stopper(patched_loop))
+
+
 @pytest.mark.skipif(not PY_37, reason="contextvars support is required")
 def test_run_app_context_vars(patched_loop):
     from contextvars import ContextVar
Repository: aio-libs/aiohttp

Issue:
ModuleNotFoundError: No module named 'typing_extensions'
🐞 **Describe the bug**
<!-- A clear and concise description of what the bug is, on the next line. -->

After updating aiohttp from 3.6.2 to 3.7.0, the [gql](https://github.com/graphql-python/gql) tests are failing on python 3.8 with the Exception `ModuleNotFoundError: No module named 'typing_extensions'`

```
tests/conftest.py:15: in <module>
    from aiohttp.test_utils import TestServer as AIOHTTPTestServer
.tox/py38/lib/python3.8/site-packages/aiohttp/test_utils.py:43: in <module>
    from .web import (
.tox/py38/lib/python3.8/site-packages/aiohttp/web.py:23: in <module>
    from .web_app import Application as Application
.tox/py38/lib/python3.8/site-packages/aiohttp/web_app.py:39: in <module>
    from .web_middlewares import _fix_request_current_app
.tox/py38/lib/python3.8/site-packages/aiohttp/web_middlewares.py:7: in <module>
    from .web_urldispatcher import SystemRoute
.tox/py38/lib/python3.8/site-packages/aiohttp/web_urldispatcher.py:36: in <module>
    from typing_extensions import TypedDict
E   ModuleNotFoundError: No module named 'typing_extensions'

```

💡 **To Reproduce**

Check the PR [#156](https://github.com/graphql-python/gql/pull/156)


Discussion:
Probably related to the aiohttp PR #5078 (6 days ago)

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -71,7 +71,7 @@ def build_extension(self, ext):
     "async_timeout>=3.0,<4.0",
     "yarl>=1.0,<2.0",
     'idna-ssl>=1.0; python_version<"3.7"',
-    'typing_extensions>=3.6.5; python_version<"3.7"',
+    "typing_extensions>=3.6.5",
 ]
 
 


Test patch:
diff --git a/tests/test_web_functional.py b/tests/test_web_functional.py
--- a/tests/test_web_functional.py
+++ b/tests/test_web_functional.py
@@ -1952,7 +1952,8 @@ async def handler(request):
 
 
 @pytest.mark.parametrize(
-    "status", [101, 204],
+    "status",
+    [101, 204],
 )
 async def test_response_101_204_no_content_length_http11(
     status, aiohttp_client
Repository: aio-libs/aiohttp

Issue:
TypeError in web.py - '<' not supported between instances of 'sys.version_info' and 'float'
🐞 **Describe the bug**
<!-- A clear and concise description of what the bug is, on the next line. -->

💡 **To Reproduce**

1. Windows, Python 3.9.0 x64
2. "from aiohttp import web"


📋 **Logs/tracebacks**
<!-- If applicable, add logs/tracebacks to help explain your problem. -->
```python-traceback (paste your traceback in the next line)
 File "C:\_dev\.venv\lib\site-packages\aiohttp\web.py", line 379, in _run_app
    if sys.platform == "win32" and sys.version_info < 3.8:
TypeError: '<' not supported between instances of 'sys.version_info' and 'float'

```

📋 **Your version of the Python**
<!-- Attach your version of the Python. -->
```console
$ python --version
Python 3.9.0
...
```

📋 **Your version of the aiohttp/yarl/multidict distributions**
<!-- Attach your version of the distributions in the code blocks below. -->
```console
$ python -m pip show aiohttp
Name: aiohttp
Version: 3.7.0
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author: Nikolay Kim
Author-email: fafhrd91@gmail.com
License: Apache 2
Location: c:\_dev\.venv\lib\site-packages
Requires: async-timeout, multidict, chardet, yarl, attrs
```
```console
$ python -m pip show multidict
Name: multidict
Version: 5.0.0
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache 2
Location: c:\_dev\.venv\lib\site-packages
Requires:
Required-by: yarl, aiohttp
```
```console
$ python -m pip show yarl
Name: yarl
Version: 1.6.2
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl/
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache 2
Location: c:\_dev\.venv\lib\site-packages
Requires: multidict, idna
Required-by: aiormq, aiohttp, aio-pika
```

📋 **Additional context**
<!-- Add any other context about the problem here, in the next line. -->
This can be reproduced by simply doing:
import sys
print(sys.version_info < 3.8)



Discussion:
same here. windows 2012
same error : 

> TypeError: '<' not supported between instances of 'sys.version_info' and 'float'

Name: aiohttp Version: 3.7.0 not work, but Version: 3.6.2 work well

Resolving patch:
diff --git a/aiohttp/web.py b/aiohttp/web.py
--- a/aiohttp/web.py
+++ b/aiohttp/web.py
@@ -420,7 +420,7 @@ async def _run_app(
         # sleep forever by 1 hour intervals,
         # on Windows before Python 3.8 wake up every 1 second to handle
         # Ctrl+C smoothly
-        if sys.platform == "win32" and sys.version_info < 3.8:
+        if sys.platform == "win32" and sys.version_info < (3, 8):
             delay = 1
         else:
             delay = 3600


Test patch:
Repository: aio-libs/aiohttp

Issue:
Setting empty str as data does not set text/plain header
Setting empty str as data does not set text/plain header
```
await session.post(url, data='')
```
will set
```
'Content-Type': 'application/octet-stream'
```
in the header.

Expected would be
```
'Content-Type': 'text/plain'
```

This is also described in the [docs](https://docs.aiohttp.org/en/stable/client_advanced.html#custom-request-headers).
It shows ``data`` as a shortcut for ``text/plain``.

📋 **Versions**
<!-- Attach your version of the Python. -->
```console
Python/3.8
aiohttp/3.7.3
```



Discussion:

Resolving patch:
diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py
--- a/aiohttp/client_reqrep.py
+++ b/aiohttp/client_reqrep.py
@@ -245,7 +245,7 @@ def __init__(
         self.update_proxy(proxy, proxy_auth, proxy_headers)
 
         self.update_body_from_data(data)
-        if data or self.method not in self.GET_METHODS:
+        if data is not None or self.method not in self.GET_METHODS:
             self.update_transfer_encoding()
         self.update_expect_continue(expect100)
         if traces is None:
@@ -383,7 +383,7 @@ def update_cookies(self, cookies: Optional[LooseCookies]) -> None:
 
     def update_content_encoding(self, data: Any) -> None:
         """Set request content encoding."""
-        if not data:
+        if data is None:
             return
 
         enc = self.headers.get(hdrs.CONTENT_ENCODING, "").lower()
@@ -433,7 +433,7 @@ def update_auth(self, auth: Optional[BasicAuth]) -> None:
         self.headers[hdrs.AUTHORIZATION] = auth.encode()
 
     def update_body_from_data(self, body: Any) -> None:
-        if not body:
+        if body is None:
             return
 
         # FormData


Test patch:
diff --git a/tests/test_client_functional.py b/tests/test_client_functional.py
--- a/tests/test_client_functional.py
+++ b/tests/test_client_functional.py
@@ -3022,3 +3022,22 @@ async def handler(request):
 
     async with await client.get("/", read_bufsize=4) as resp:
         assert resp.content.get_read_buffer_limits() == (4, 8)
+
+
+async def test_http_empty_data_text(aiohttp_client: Any) -> None:
+    async def handler(request):
+        data = await request.read()
+        ret = "ok" if data == b"" else "fail"
+        resp = web.Response(text=ret)
+        resp.headers["Content-Type"] = request.headers["Content-Type"]
+        return resp
+
+    app = web.Application()
+    app.add_routes([web.post("/", handler)])
+
+    client = await aiohttp_client(app)
+
+    async with await client.post("/", data="") as resp:
+        assert resp.status == 200
+        assert await resp.text() == "ok"
+        assert resp.headers["Content-Type"] == "text/plain; charset=utf-8"
Repository: aio-libs/aiohttp

Issue:
[TODO] Use an SVG logo in the Sphinx docs
🐣 **Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
I noticed that the sphinx docs use a non-scalable png file as a logo. It needs to be changed.

💡 **Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->
Use https://github.com/aio-libs/aiohttp/blob/master/docs/aiohttp-plain.svg in sphinx instead.

❓ **Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
N/A

📋 **Additional context**
<!-- Add any other context or screenshots about the feature request here. -->
N/A


Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -146,7 +146,6 @@
 # further.  For a list of options available for each theme, see the
 # documentation.
 html_theme_options = {
-    "logo": "aiohttp-icon-128x128.png",
     "description": "Async HTTP client/server for asyncio and Python",
     "canonical_url": "http://docs.aiohttp.org/en/stable/",
     "github_user": "aio-libs",
@@ -188,6 +187,10 @@
     ],
 }
 
+html_css_files = [
+    "css/logo-adjustments.css",
+]
+
 # Add any paths that contain custom themes here, relative to this directory.
 # html_theme_path = [alabaster.get_path()]
 
@@ -200,7 +203,7 @@
 
 # The name of an image file (relative to this directory) to place at the top
 # of the sidebar.
-# html_logo = 'aiohttp-icon.svg'
+html_logo = "aiohttp-plain.svg"
 
 # The name of an image file (within the static path) to use as favicon of the
 # docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32


Test patch:
Repository: aio-libs/aiohttp

Issue:
optional auto_decompress for HttpRequestParser
### Is your feature request related to a problem?

auto_decompress can be disabled for client but unfortunately not for server.

### Describe the solution you'd like

Export the API (I'm going to open a PR few minutes after filing this issue)

### Describe alternatives you've considered

The feature can be hacked by setting `AIOHTTP_NO_EXTENSIONS=true` and

```
request_handler_init = web.RequestHandler.__init__

def disable_decompression(self, *args, **kwargs):
    request_handler_init(self, *args, **kwargs)
    self._request_parser._auto_decompress = False

web.RequestHandler.__init__ = disable_decompression
```

but that is ugly and slow.

### Related component

Server

### Additional context

_No response_

### Code of Conduct

- [X] I agree to follow the aio-libs Code of Conduct


Discussion:

Resolving patch:
diff --git a/aiohttp/web_protocol.py b/aiohttp/web_protocol.py
--- a/aiohttp/web_protocol.py
+++ b/aiohttp/web_protocol.py
@@ -194,6 +194,7 @@ def __init__(
         max_field_size: int = 8190,
         lingering_time: float = 10.0,
         read_bufsize: int = 2 ** 16,
+        auto_decompress: bool = True,
     ):
         super().__init__(loop)
 
@@ -227,6 +228,7 @@ def __init__(
             max_field_size=max_field_size,
             max_headers=max_headers,
             payload_exception=RequestPayloadError,
+            auto_decompress=auto_decompress,
         )  # type: Optional[HttpRequestParser]
 
         self.logger = logger


Test patch:
diff --git a/tests/test_web_functional.py b/tests/test_web_functional.py
--- a/tests/test_web_functional.py
+++ b/tests/test_web_functional.py
@@ -1896,6 +1896,32 @@ async def handler(request):
     assert await resp.text() == "data (2, 4)"
 
 
+@pytest.mark.parametrize(
+    "auto_decompress,len_of", [(True, "uncompressed"), (False, "compressed")]
+)
+async def test_auto_decompress(
+    aiohttp_client: Any,
+    auto_decompress: bool,
+    len_of: str,
+) -> None:
+    async def handler(request):
+        data = await request.read()
+        return web.Response(text=str(len(data)))
+
+    app = web.Application(handler_args={"auto_decompress": auto_decompress})
+    app.router.add_post("/", handler)
+
+    client = await aiohttp_client(app)
+    uncompressed = b"dataaaaaaaaaaaaaaaaaaaaaaaaa"
+    compressor = zlib.compressobj(wbits=16 + zlib.MAX_WBITS)
+    compressed = compressor.compress(uncompressed) + compressor.flush()
+    assert len(compressed) != len(uncompressed)
+    headers = {"content-encoding": "gzip"}
+    resp = await client.post("/", data=compressed, headers=headers)
+    assert resp.status == 200
+    assert await resp.text() == str(len(locals()[len_of]))
+
+
 @pytest.mark.parametrize(
     "status",
     [101, 204],