Update flake8 and dependencies (#13953)

diff --git a/tools/ci/tcdownload.py b/tools/ci/tcdownload.py
index 8813dcc..91c763a 100644
--- a/tools/ci/tcdownload.py
+++ b/tools/ci/tcdownload.py
@@ -89,7 +89,11 @@
                     logger.info(path)
 
 
-def __main__():
+def main():
     kwargs = get_parser().parse_args()
 
     run(None, vars(kwargs))
+
+
+if __name__ == "__main__":
+    main()
diff --git a/tools/py27-flake8.ini b/tools/py27-flake8.ini
index 1a5ce43..99324b2 100644
--- a/tools/py27-flake8.ini
+++ b/tools/py27-flake8.ini
@@ -11,10 +11,14 @@
 # E305: expected 2 blank lines after end of function or class
 # E402: module level import not at top of file
 # E731: do not assign a lambda expression, use a def
+# W504: line break after binary operator
 # W601: .has_key() is deprecated, use ‘in’
+# W605: invalid escape sequence
+# W606: 'async' and 'await' are reserved keywords starting with Python 3.7
 # N801: class names should use CapWords convention
 # N802: function name should be lowercase
-ignore = E128,E129,E226,E231,E251,E265,E302,E303,E305,E402,E731,W601,N801,N802
+# N806: variable in function should be lowercase
+ignore = E128,E129,E226,E231,E251,E265,E302,E303,E305,E402,E731,W504,W601,W605,W606,N801,N802,N806
 exclude =
     .tox,
     pywebsocket,
diff --git a/tools/py36-flake8.ini b/tools/py36-flake8.ini
index 9b01f22..4ad3410 100644
--- a/tools/py36-flake8.ini
+++ b/tools/py36-flake8.ini
@@ -11,9 +11,11 @@
 # E305: expected 2 blank lines after end of function or class
 # E402: module level import not at top of file
 # E731: do not assign a lambda expression, use a def
+# W504: line break after binary operator
+# W605: invalid escape sequence
 # N801: class names should use CapWords convention
 # N802: function name should be lowercase
-ignore = E128,E129,E226,E231,E251,E265,E302,E303,E305,E402,E731,N801,N802
+ignore = E128,E129,E226,E231,E251,E265,E302,E303,E305,E402,E731,W504,W605,N801,N802
 exclude =
     .tox,
     pywebsocket,
diff --git a/tools/requirements_flake8.txt b/tools/requirements_flake8.txt
index 6d6ee4d..d07642d 100644
--- a/tools/requirements_flake8.txt
+++ b/tools/requirements_flake8.txt
@@ -1,4 +1,4 @@
-flake8==3.5.0
-pycodestyle==2.3.1
+flake8==3.6.0
+pycodestyle==2.4.0
 pyflakes==1.6.0
-pep8-naming==0.4.1
+pep8-naming==0.7.0
diff --git a/tools/wptserve/wptserve/handlers.py b/tools/wptserve/wptserve/handlers.py
index 7fbe423..2dd01e2 100644
--- a/tools/wptserve/wptserve/handlers.py
+++ b/tools/wptserve/wptserve/handlers.py
@@ -7,8 +7,6 @@
 from six.moves.urllib.parse import parse_qs, quote, unquote, urljoin
 from six import iteritems
 
-from h2.events import RequestReceived, DataReceived
-
 from .constants import content_types
 from .pipes import Pipeline, template
 from .ranges import RangeParser
@@ -79,7 +77,7 @@
 %(items)s
 </ul>
 """ % {"path": cgi.escape(url_path),
-       "items": "\n".join(self.list_items(url_path, path))}  # flake8: noqa
+       "items": "\n".join(self.list_items(url_path, path))}  # noqa: E122
 
     def list_items(self, base_path, path):
         assert base_path.endswith("/")