diff --git a/.gitignore b/.gitignore index b24b4f49cce77c60043a94a34c37d29398867853..ba4027b5b3606430492c6a7b5d4a8f977b765546 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__ .coverage + .ipynb_checkpoints diff --git a/ci/mypy.sh b/ci/mypy.sh index 65d6a91267c38125d277d77c9160f1a51ad8f5e8..878b51cf1a2cfb52ef0e5cc35c68206cf4b36f9d 100644 --- a/ci/mypy.sh +++ b/ci/mypy.sh @@ -1,8 +1,5 @@ #!/bin/bash -# What percentage of the code has to be annotated -THRESHOLD=0.75 - # Create Log file touch mypy_output.txt @@ -26,18 +23,16 @@ for directory in $( cat directories.txt ); do done # If nothing has been checked -if [[ $nPasses == 0 && $nErrors == 0 ]]; then +if [[ $nPasses == 0 ]]; then echo "mypy hasn't found any code to check" - exit 0 -else - # Calculate the ratio of errors - percentage=$( python3 -c "print($nPasses/($nErrors+$nPasses))" ) + exit 1 fi rm linecount.txt -if [[ $percentage > $THRESHOLD ]]; then - echo "The number of type-errors is below the threshold. Check passed" +if [[ $nErrors -eq 0 ]]; then + echo "No errors found. Check passed" + echo "mypy checked ${nPasses} lines of code" # Create new Badge rm mypy.svg @@ -45,7 +40,7 @@ if [[ $percentage > $THRESHOLD ]]; then exit 0 else - echo "mypy found enough errors in the code. You might want to check your code again" + echo "mypy found errors in the code. You might want to check your code again" echo "Maybe take a look at mypy_output.txt" # Create Badge diff --git a/src/main.py b/src/main.py index e2d989cba1d3971b2340a32abb8755a79bd1dae6..92840766f68ca8d6cbb10f578eae5c4952e4b31d 100644 --- a/src/main.py +++ b/src/main.py @@ -1,5 +1,7 @@ +from typing import Any + class Test: - def __init__(self, arg: any): + def __init__(self, arg: Any) -> None: """Test.""" print(arg) diff --git a/src/test_sample.py b/src/test_sample.py index fdd24f158df16bade504c12957ffa24386b7c132..3c23ddc5c272b5b0d2c1a1c1fae7d358eb6d6c32 100644 --- a/src/test_sample.py +++ b/src/test_sample.py @@ -2,5 +2,5 @@ def inc(x: int) -> int: return x + 1 -def test_answer(): +def test_answer() -> None: assert inc(3) ==4