From 997b496a68627972d17aa5858926f9f96c0767da Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 26 Aug 2020 23:33:15 +0200 Subject: [PATCH 1/4] update flake8 and mypy --- setup.cfg | 2 +- tox.ini | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index c9c19704f..5006359f1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [flake8] max-line-length = 140 max-complexity = 25 -ignore = E251,E252,C901,W292,W503,W504,W605,E722,E741,E126 +ignore = E251,E252,C901,W292,W503,W504,W605,E722,E741,E126,F541 exclude = mitmproxy/contrib/*,test/mitmproxy/data/*,release/build/*,mitmproxy/io/proto/* addons = file,open,basestring,xrange,unicode,long,cmp diff --git a/tox.ini b/tox.ini index a4c7b37cf..47582a54d 100644 --- a/tox.ini +++ b/tox.ini @@ -23,7 +23,7 @@ commands = bash -c "mitmdump --version 2>&1 | grep 'mitmproxy requires Python 3.6'" [testenv:flake8] -deps = flake8>=3.7.8,<3.8 +deps = flake8==3.8 commands = flake8 --jobs 8 mitmproxy pathod examples test release @@ -32,7 +32,7 @@ commands = python ./test/filename_matching.py [testenv:mypy] -deps = mypy>=0.761,<0.762 +deps = mypy==0.782 commands = mypy . @@ -52,7 +52,7 @@ passenv = CI_* GITHUB_* AWS_* TWINE_* DOCKER_* deps = -rrequirements.txt pyinstaller==3.5 - twine==3.1.1 + twine==3.2.0 awscli commands = mitmdump --version From cd4425652108b8d2ccf4806ed5a662bbdf416c7d Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 26 Aug 2020 23:36:32 +0200 Subject: [PATCH 2/4] update various dependencies --- setup.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index c9c663c8a..9ab4438d6 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ setup( "Brotli>=1.0,<1.1", "certifi>=2019.9.11", # no semver here - this should always be on the last release! "click>=7.0,<8", - "cryptography>=2.9,<3.0", + "cryptography>=3.0,<3.1", "flask>=1.1.1,<1.2", "h2>=3.2.0,<4", "hyperframe>=5.1.0,<6", @@ -74,18 +74,18 @@ setup( "ldap3>=2.8,<2.9", "msgpack>=1.0.0, <1.1.0", "passlib>=1.6.5, <1.8", - "protobuf>=3.6.0, <3.12", + "protobuf>=3.6.0, <3.14", "pyasn1>=0.3.1,<0.5", "pyOpenSSL>=19.1.0,<19.2", "pyparsing>=2.4.2,<2.5", "pyperclip>=1.6.0,<1.9", "ruamel.yaml>=0.16,<0.17", - "sortedcontainers>=2.1.0,<2.2", + "sortedcontainers>=2.1,<2.3", "tornado>=4.3,<7", "urwid>=2.1.1,<2.2", "wsproto>=0.14,<0.16", "publicsuffix2>=2.20190812,<3", - "zstandard>=0.11,<0.14", + "zstandard>=0.11,<0.15", ], extras_require={ ':sys_platform == "win32"': [ @@ -97,15 +97,15 @@ setup( 'dev': [ "asynctest>=0.12.0", "Flask>=1.0,<1.2", - "hypothesis>=5.8,<5.9", + "hypothesis>=5.8,<5.30", "parver>=0.1,<2.0", - "pytest-asyncio>=0.10.0,<0.11", + "pytest-asyncio>=0.10.0,<0.14", "pytest-cov>=2.7.1,<3", "pytest-timeout>=1.3.3,<2", - "pytest-xdist>=1.29,<2", - "pytest>=5.1.3,<6", + "pytest-xdist>=1.29,<2.2", + "pytest>=5.1.3,<7", "requests>=2.9.1,<3", - "tox>=3.5,<3.15", + "tox>=3.5,<3.20", ] } ) From 83dac0e999317f502496e6181fb835e5ee41ee1c Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 26 Aug 2020 23:47:46 +0200 Subject: [PATCH 3/4] make mypy happy --- mitmproxy/optmanager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mitmproxy/optmanager.py b/mitmproxy/optmanager.py index ac85f83a3..30d02d7fe 100644 --- a/mitmproxy/optmanager.py +++ b/mitmproxy/optmanager.py @@ -26,7 +26,7 @@ class _Option: def __init__( self, name: str, - typespec: type, + typespec: typing.Union[type, object], # object for Optional[x], which is not a type. default: typing.Any, help: str, choices: typing.Optional[typing.Sequence[str]] @@ -101,7 +101,7 @@ class OptManager: def add_option( self, name: str, - typespec: type, + typespec: typing.Union[type, object], default: typing.Any, help: str, choices: typing.Optional[typing.Sequence[str]] = None From e31f69ff4a165051dd74433ddedc600633f8e4c3 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 27 Aug 2020 00:08:23 +0200 Subject: [PATCH 4/4] fix windows tests failing due to tornado bug --- mitmproxy/__init__.py | 1 + test/mitmproxy/tools/web/test_app.py | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/mitmproxy/__init__.py b/mitmproxy/__init__.py index e930cf1e4..9deef9605 100644 --- a/mitmproxy/__init__.py +++ b/mitmproxy/__init__.py @@ -5,4 +5,5 @@ if sys.platform == 'win32': # workaround for # https://github.com/tornadoweb/tornado/issues/2751 # https://www.tornadoweb.org/en/stable/index.html#installation + # (copied multiple times in the codebase, please remove all occurrences) asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) diff --git a/test/mitmproxy/tools/web/test_app.py b/test/mitmproxy/tools/web/test_app.py index 668d3c07d..2cd34af20 100644 --- a/test/mitmproxy/tools/web/test_app.py +++ b/test/mitmproxy/tools/web/test_app.py @@ -3,16 +3,25 @@ import logging from unittest import mock import os import asyncio +import sys import pytest -import tornado.testing -from tornado import httpclient -from tornado import websocket -from mitmproxy import options -from mitmproxy.test import tflow -from mitmproxy.tools.web import app -from mitmproxy.tools.web import master as webmaster +if sys.platform == 'win32': + # workaround for + # https://github.com/tornadoweb/tornado/issues/2751 + # https://www.tornadoweb.org/en/stable/index.html#installation + # (copied multiple times in the codebase, please remove all occurrences) + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) + +import tornado.testing # noqa +from tornado import httpclient # noqa +from tornado import websocket # noqa + +from mitmproxy import options # noqa +from mitmproxy.test import tflow # noqa +from mitmproxy.tools.web import app # noqa +from mitmproxy.tools.web import master as webmaster # noqa @pytest.fixture(scope="module")