cleanup mypy usage

This commit is contained in:
Maximilian Hils 2019-11-16 14:56:01 +01:00
parent d17b9d6230
commit ac22aee2f5
8 changed files with 17 additions and 25 deletions

View File

@ -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

View File

@ -24,4 +24,4 @@ def request(flow: http.HTTPFlow) -> None:
return return
address = proxy_address(flow) address = proxy_address(flow)
if flow.live: if flow.live:
flow.live.change_upstream_proxy_server(address) flow.live.change_upstream_proxy_server(address) # type: ignore

View File

@ -31,6 +31,7 @@ def request(flow: http.HTTPFlow) -> None:
def response(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('Strict-Transport-Security', None)
flow.response.headers.pop('Public-Key-Pins', None) flow.response.headers.pop('Public-Key-Pins', None)

View File

@ -395,8 +395,10 @@ def get_XSS_data(body: Union[str, bytes], request_URL: str, injection_point: str
# response is mitmproxy's entry point # response is mitmproxy's entry point
def response(flow: http.HTTPFlow) -> None: def response(flow: http.HTTPFlow) -> None:
assert flow.response
cookies_dict = get_cookies(flow) cookies_dict = get_cookies(flow)
resp = flow.response.get_text(strict=False) resp = flow.response.get_text(strict=False)
assert resp
# Example: http://xss.guru/unclaimedScriptTag.html # Example: http://xss.guru/unclaimedScriptTag.html
find_unclaimed_URLs(resp, flow.request.url) find_unclaimed_URLs(resp, flow.request.url)
results = test_end_of_URL_injection(resp, flow.request.url, cookies_dict) results = test_end_of_URL_injection(resp, flow.request.url, cookies_dict)

View File

@ -190,7 +190,9 @@ class BuildEnviron:
""" """
with open(pathlib.Path(self.root_dir) / "mitmproxy" / "version.py") as f: with open(pathlib.Path(self.root_dir) / "mitmproxy" / "version.py") as f:
contents = f.read() 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: if self.is_prod_release:
# For production releases, we require strict version equality # For production releases, we require strict version equality

View File

@ -19,12 +19,18 @@ exclude_lines =
pragma: no cover pragma: no cover
raise NotImplementedError() raise NotImplementedError()
[mypy]
ignore_missing_imports = True
[mypy-mitmproxy.contrib.*] [mypy-mitmproxy.contrib.*]
ignore_errors = True ignore_errors = True
[mypy-tornado.*] [mypy-tornado.*]
ignore_errors = True ignore_errors = True
[mypy-test.*]
ignore_errors = True
[tool:full_coverage] [tool:full_coverage]
exclude = exclude =
mitmproxy/proxy/protocol/base.py mitmproxy/proxy/protocol/base.py

View File

@ -13,7 +13,9 @@ with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read() long_description = f.read()
with open(os.path.join(here, "mitmproxy", "version.py")) as f: 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( setup(
name="mitmproxy", name="mitmproxy",

View File

@ -31,8 +31,7 @@ commands =
flake8 --jobs 8 mitmproxy pathod examples test release flake8 --jobs 8 mitmproxy pathod examples test release
python ./test/filename_matching.py python ./test/filename_matching.py
rstcheck README.rst rstcheck README.rst
mypy --ignore-missing-imports ./mitmproxy ./pathod mypy .
mypy --ignore-missing-imports --follow-imports=skip ./examples/simple/ ./examples/pathod/ ./examples/complex/
[testenv:individual_coverage] [testenv:individual_coverage]
deps = deps =