aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2019-11-16 14:56:01 +0100
committerMaximilian Hils <git@maximilianhils.com>2019-11-16 15:14:30 +0100
commitac22aee2f512cefd298fe0d9563a5de0ef7e42ee (patch)
tree131017b6a63eef67d676f106731989fab3525bce
parentd17b9d62305507a93836eb6ee085fa3edd029bed (diff)
downloadmitmproxy-ac22aee2f512cefd298fe0d9563a5de0ef7e42ee.tar.gz
mitmproxy-ac22aee2f512cefd298fe0d9563a5de0ef7e42ee.tar.bz2
mitmproxy-ac22aee2f512cefd298fe0d9563a5de0ef7e42ee.zip
cleanup mypy usage
-rw-r--r--.landscape.yml20
-rw-r--r--examples/complex/change_upstream_proxy.py2
-rw-r--r--examples/complex/sslstrip.py1
-rwxr-xr-xexamples/complex/xss_scanner.py2
-rwxr-xr-xrelease/cibuild.py4
-rw-r--r--setup.cfg6
-rw-r--r--setup.py4
-rw-r--r--tox.ini3
8 files changed, 17 insertions, 25 deletions
diff --git a/.landscape.yml b/.landscape.yml
deleted file mode 100644
index b6a45ed7..00000000
--- a/.landscape.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-ignore-paths:
- - docs
- - examples
- - mitmproxy/contrib
- - web
-max-line-length: 140
-pylint:
- options:
- dummy-variables-rgx: _$|.+_$|dummy_.+
- disable:
- - missing-docstring
- - protected-access
- - too-few-public-methods
- - too-many-arguments
- - too-many-instance-attributes
- - too-many-locals
- - too-many-public-methods
- - too-many-return-statements
- - too-many-statements
- - unpacking-non-sequence
diff --git a/examples/complex/change_upstream_proxy.py b/examples/complex/change_upstream_proxy.py
index 089a9df5..a0e7e572 100644
--- a/examples/complex/change_upstream_proxy.py
+++ b/examples/complex/change_upstream_proxy.py
@@ -24,4 +24,4 @@ def request(flow: http.HTTPFlow) -> None:
return
address = proxy_address(flow)
if flow.live:
- flow.live.change_upstream_proxy_server(address)
+ flow.live.change_upstream_proxy_server(address) # type: ignore
diff --git a/examples/complex/sslstrip.py b/examples/complex/sslstrip.py
index 69b9ea9e..8b904216 100644
--- a/examples/complex/sslstrip.py
+++ b/examples/complex/sslstrip.py
@@ -31,6 +31,7 @@ def request(flow: http.HTTPFlow) -> None:
def response(flow: http.HTTPFlow) -> None:
+ assert flow.response
flow.response.headers.pop('Strict-Transport-Security', None)
flow.response.headers.pop('Public-Key-Pins', None)
diff --git a/examples/complex/xss_scanner.py b/examples/complex/xss_scanner.py
index d5f4aaab..2a45511a 100755
--- a/examples/complex/xss_scanner.py
+++ b/examples/complex/xss_scanner.py
@@ -395,8 +395,10 @@ def get_XSS_data(body: Union[str, bytes], request_URL: str, injection_point: str
# response is mitmproxy's entry point
def response(flow: http.HTTPFlow) -> None:
+ assert flow.response
cookies_dict = get_cookies(flow)
resp = flow.response.get_text(strict=False)
+ assert resp
# Example: http://xss.guru/unclaimedScriptTag.html
find_unclaimed_URLs(resp, flow.request.url)
results = test_end_of_URL_injection(resp, flow.request.url, cookies_dict)
diff --git a/release/cibuild.py b/release/cibuild.py
index 82060639..799c7929 100755
--- a/release/cibuild.py
+++ b/release/cibuild.py
@@ -190,7 +190,9 @@ class BuildEnviron:
"""
with open(pathlib.Path(self.root_dir) / "mitmproxy" / "version.py") as f:
contents = f.read()
- version = re.search(r'^VERSION = "(.+?)"', contents, re.M).group(1)
+ match = re.search(r'^VERSION = "(.+?)"', contents, re.M)
+ assert match
+ version = match.group(1)
if self.is_prod_release:
# For production releases, we require strict version equality
diff --git a/setup.cfg b/setup.cfg
index e7643b08..a2c49f48 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -19,12 +19,18 @@ exclude_lines =
pragma: no cover
raise NotImplementedError()
+[mypy]
+ignore_missing_imports = True
+
[mypy-mitmproxy.contrib.*]
ignore_errors = True
[mypy-tornado.*]
ignore_errors = True
+[mypy-test.*]
+ignore_errors = True
+
[tool:full_coverage]
exclude =
mitmproxy/proxy/protocol/base.py
diff --git a/setup.py b/setup.py
index 9343dd99..fb23fd69 100644
--- a/setup.py
+++ b/setup.py
@@ -13,7 +13,9 @@ with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
with open(os.path.join(here, "mitmproxy", "version.py")) as f:
- VERSION = re.search(r'VERSION = "(.+?)"', f.read()).group(1)
+ match = re.search(r'VERSION = "(.+?)"', f.read())
+ assert match
+ VERSION = match.group(1)
setup(
name="mitmproxy",
diff --git a/tox.ini b/tox.ini
index 8c8fbaa2..3df2bd40 100644
--- a/tox.ini
+++ b/tox.ini
@@ -31,8 +31,7 @@ commands =
flake8 --jobs 8 mitmproxy pathod examples test release
python ./test/filename_matching.py
rstcheck README.rst
- mypy --ignore-missing-imports ./mitmproxy ./pathod
- mypy --ignore-missing-imports --follow-imports=skip ./examples/simple/ ./examples/pathod/ ./examples/complex/
+ mypy .
[testenv:individual_coverage]
deps =