diff --git a/mitmproxy/addons/script.py b/mitmproxy/addons/script.py index 3ac4baa28..4e146d67d 100644 --- a/mitmproxy/addons/script.py +++ b/mitmproxy/addons/script.py @@ -29,6 +29,7 @@ def load_script(path: str) -> typing.Optional[types.ModuleType]: try: loader = importlib.machinery.SourceFileLoader(fullname, path) spec = importlib.util.spec_from_loader(fullname, loader=loader) + assert spec m = importlib.util.module_from_spec(spec) loader.exec_module(m) if not getattr(m, "name", None): diff --git a/mitmproxy/platform/windows.py b/mitmproxy/platform/windows.py index 46047a954..b447a7517 100644 --- a/mitmproxy/platform/windows.py +++ b/mitmproxy/platform/windows.py @@ -17,6 +17,12 @@ import collections.abc import pydivert import pydivert.consts +if typing.TYPE_CHECKING: + class WindowsError(OSError): + @property + def winerror(self) -> int: + return 42 + REDIRECT_API_HOST = "127.0.0.1" REDIRECT_API_PORT = 8085 diff --git a/tox.ini b/tox.ini index 591e25c58..8963dcf6f 100644 --- a/tox.ini +++ b/tox.ini @@ -28,7 +28,14 @@ commands = python ./test/filename_matching.py [testenv:mypy] -deps = mypy==0.812 +deps = + mypy==0.902 + types-certifi==0.1.3 + types-Flask==1.1.0 + types-Werkzeug==1.0.1 + types-requests==0.1.11 + types-cryptography==3.3.2 + commands = mypy {posargs}