From f34a00035238c74940c364a152cace81ba3eccde Mon Sep 17 00:00:00 2001 From: Arijit Basu Date: Thu, 29 Aug 2019 14:12:33 +0530 Subject: [PATCH] Add sayanarijit/typecov (#37) Ref: https://github.com/niteoweb/operations/issues/1070 --- .mypy/type_coverage.py | 44 ------------------------------------------ .travis.yml | 2 +- Pipfile | 3 ++- Pipfile.lock | 10 +++++++++- 4 files changed, 12 insertions(+), 47 deletions(-) delete mode 100644 .mypy/type_coverage.py diff --git a/.mypy/type_coverage.py b/.mypy/type_coverage.py deleted file mode 100644 index cf4b132..0000000 --- a/.mypy/type_coverage.py +++ /dev/null @@ -1,44 +0,0 @@ -"""Verify that minimum type coverage is reached.""" - -import argparse -import sys - - -def main(argv=sys.argv) -> None: # pragma: no cover - """Run type coverage check.""" - parser = argparse.ArgumentParser( - usage=("python type_coverage.py coverage=80 file=typecov/linecount.txt \n") - ) - parser.add_argument( - "coverage", - type=float, - metavar="", - help="Minimum required type coverage.", - ) - parser.add_argument( - "file", - type=argparse.FileType("r"), - metavar="", - help="File with line count type coverage report.", - ) - args = parser.parse_args() - min_coverage = args.coverage - coverage_summary = args.file.readline() - if not coverage_summary: - sys.stdout.write(f"ERROR Line count report file {args.file.name} is empty.\n") - sys.exit(1) - values = coverage_summary.split() - coverage = int(values[0]) / int(values[1]) * 100 - - if coverage >= min_coverage: - sys.stdout.write(f"Total coverage: {coverage}%\n") - sys.exit(0) - else: - sys.stdout.write( - f"FAIL Required type coverage of {min_coverage}% not reached. Total coverage: {coverage}%\n" - ) - sys.exit(1) - - -if __name__ == "__main__": - main() diff --git a/.travis.yml b/.travis.yml index 0fa6edb..56c9554 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,4 +17,4 @@ script: - pipenv run coverage report --fail-under=100 - pipenv run black pyramid_heroku/ --check - pipenv run mypy pyramid_heroku --ignore-missing-imports --linecount-report typecov - - pipenv run python .mypy/type_coverage.py 15 typecov/linecount.txt + - pipenv run typecov 15 typecov/linecount.txt diff --git a/Pipfile b/Pipfile index 89d949a..ae44c5e 100644 --- a/Pipfile +++ b/Pipfile @@ -4,7 +4,7 @@ verify_ssl = true name = "pypi" [packages] -pyramid-heroku = {editable = true, path = "."} +pyramid-heroku = {editable = true,path = "."} expandvars = "*" [dev-packages] @@ -17,6 +17,7 @@ docutils = "*" structlog = "*" black = "==18.9b0" mypy = "*" +typecov = "*" [requires] python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock index c9097e8..8c329a6 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "1b6ac89ce7ebbc7c3032c33e60eb54b7014cdfaccd79bede92457df134ea1281" + "sha256": "9d41fca0afc6d664be9f78ea1e57ed666e22ce109b1a06daf3a03b30b4874dfe" }, "pipfile-spec": 6, "requires": { @@ -386,6 +386,14 @@ ], "version": "==0.10.0" }, + "typecov": { + "hashes": [ + "sha256:817c9319e321ef50c591abc603681bea3ec84c7b21abb026724ab74569ae56ee", + "sha256:97acc6982794c841226760faf838a978de1cf74c628821e7e2622aee059ef68f" + ], + "index": "pypi", + "version": "==0.2.1" + }, "typed-ast": { "hashes": [ "sha256:18511a0b3e7922276346bcb47e2ef9f38fb90fd31cb9223eed42c85d1312344e",