Repository: aio-libs/aiohttp

Issue:
Deprecation warning in web_response.py with Python 3.7
## Long story short

When warnings are enabled, a warning like this is printed on importing `aiohttp.web` with Python 3.7:

```
/Users/dmajda/tmp/warnings/aiohttp/.venv/lib/python3.7/site-packages/aiohttp/web_response.py:33: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  BaseClass = collections.MutableMapping
```

This pullutes the output of our test suite (for which we have warnings enabled).

## Expected behaviour

No warning gets printed when importing `aiohttp.web`.

## Actual behaviour

A warning gets printed when importing `aiohttp.web`.

## Steps to reproduce

```console
$ python3 --version
Python 3.7.0
$ python3 -m venv .venv
[...]
$ . .venv/bin/activate
$ pip3 install aiohttp
[...]
$ python3 -Wall -c 'import aiohttp.web'
/Users/dmajda/tmp/warnings/aiohttp/.venv/lib/python3.7/site-packages/aiohttp/web_response.py:33: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  BaseClass = collections.MutableMapping
```

## Your environment

aiohttp version: 3.5.1
Python version: 3.7.0
OS: macOS Mojave

Deprecation warning in web_response.py with Python 3.7
## Long story short

When warnings are enabled, a warning like this is printed on importing `aiohttp.web` with Python 3.7:

```
/Users/dmajda/tmp/warnings/aiohttp/.venv/lib/python3.7/site-packages/aiohttp/web_response.py:33: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  BaseClass = collections.MutableMapping
```

This pullutes the output of our test suite (for which we have warnings enabled).

## Expected behaviour

No warning gets printed when importing `aiohttp.web`.

## Actual behaviour

A warning gets printed when importing `aiohttp.web`.

## Steps to reproduce

```console
$ python3 --version
Python 3.7.0
$ python3 -m venv .venv
[...]
$ . .venv/bin/activate
$ pip3 install aiohttp
[...]
$ python3 -Wall -c 'import aiohttp.web'
/Users/dmajda/tmp/warnings/aiohttp/.venv/lib/python3.7/site-packages/aiohttp/web_response.py:33: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  BaseClass = collections.MutableMapping
```

## Your environment

aiohttp version: 3.5.1
Python version: 3.7.0
OS: macOS Mojave



Discussion:
[GitMate.io](https://gitmate.io) thinks the contributor most likely able to help you is @asvetlov.

Possibly related issues are https://github.com/aio-libs/aiohttp/issues/3273 (Deprecation warnings in 3.8), https://github.com/aio-libs/aiohttp/issues/537 (Drop python 3.3 support), https://github.com/aio-libs/aiohttp/issues/1839 (aiohttp webserver with python 3.7 broken), https://github.com/aio-libs/aiohttp/issues/676 (Python 3.4.0 support), and https://github.com/aio-libs/aiohttp/issues/3111 (Publish OS-specific binary wheels for Python 3.7 @ PYPI).
@dmajda feel free to send a PR :)
[GitMate.io](https://gitmate.io) thinks the contributor most likely able to help you is @asvetlov.

Possibly related issues are https://github.com/aio-libs/aiohttp/issues/3273 (Deprecation warnings in 3.8), https://github.com/aio-libs/aiohttp/issues/537 (Drop python 3.3 support), https://github.com/aio-libs/aiohttp/issues/1839 (aiohttp webserver with python 3.7 broken), https://github.com/aio-libs/aiohttp/issues/676 (Python 3.4.0 support), and https://github.com/aio-libs/aiohttp/issues/3111 (Publish OS-specific binary wheels for Python 3.7 @ PYPI).
@dmajda feel free to send a PR :)

Resolving patch:
diff --git a/aiohttp/web_response.py b/aiohttp/web_response.py
--- a/aiohttp/web_response.py
+++ b/aiohttp/web_response.py
@@ -1,5 +1,5 @@
 import asyncio  # noqa
-import collections  # noqa
+import collections.abc  # noqa
 import datetime
 import enum
 import json
@@ -39,7 +39,7 @@
     from .web_request import BaseRequest  # noqa
     BaseClass = MutableMapping[str, Any]
 else:
-    BaseClass = collections.MutableMapping
+    BaseClass = collections.abc.MutableMapping
 
 
 class ContentCoding(enum.Enum):


Test patch:
diff --git a/tests/test_web_response.py b/tests/test_web_response.py
--- a/tests/test_web_response.py
+++ b/tests/test_web_response.py
@@ -1,4 +1,4 @@
-import collections
+import collections.abc
 import datetime
 import gzip
 import json
@@ -94,7 +94,7 @@ def test_stream_response_eq() -> None:
 
 def test_stream_response_is_mutable_mapping() -> None:
     resp = StreamResponse()
-    assert isinstance(resp, collections.MutableMapping)
+    assert isinstance(resp, collections.abc.MutableMapping)
     resp['key'] = 'value'
     assert 'value' == resp['key']