Skip to content
Snippets Groups Projects
Commit 61f367fc authored by Christian Witzler's avatar Christian Witzler Committed by Jonathan Windgassen
Browse files

don't allow errors in mypy check

parent 4010b7ec
Branches
No related tags found
1 merge request!7don't allow errors in mypy check
__pycache__ __pycache__
.coverage .coverage
.ipynb_checkpoints
#!/bin/bash #!/bin/bash
# What percentage of the code has to be annotated
THRESHOLD=0.75
# Create Log file # Create Log file
touch mypy_output.txt touch mypy_output.txt
...@@ -26,18 +23,16 @@ for directory in $( cat directories.txt ); do ...@@ -26,18 +23,16 @@ for directory in $( cat directories.txt ); do
done done
# If nothing has been checked # If nothing has been checked
if [[ $nPasses == 0 && $nErrors == 0 ]]; then if [[ $nPasses == 0 ]]; then
echo "mypy hasn't found any code to check" echo "mypy hasn't found any code to check"
exit 0 exit 1
else
# Calculate the ratio of errors
percentage=$( python3 -c "print($nPasses/($nErrors+$nPasses))" )
fi fi
rm linecount.txt rm linecount.txt
if [[ $percentage > $THRESHOLD ]]; then if [[ $nErrors -eq 0 ]]; then
echo "The number of type-errors is below the threshold. Check passed" echo "No errors found. Check passed"
echo "mypy checked ${nPasses} lines of code"
# Create new Badge # Create new Badge
rm mypy.svg rm mypy.svg
...@@ -45,7 +40,7 @@ if [[ $percentage > $THRESHOLD ]]; then ...@@ -45,7 +40,7 @@ if [[ $percentage > $THRESHOLD ]]; then
exit 0 exit 0
else 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" echo "Maybe take a look at mypy_output.txt"
# Create Badge # Create Badge
......
from typing import Any
class Test: class Test:
def __init__(self, arg: any): def __init__(self, arg: Any) -> None:
"""Test.""" """Test."""
print(arg) print(arg)
......
...@@ -2,5 +2,5 @@ def inc(x: int) -> int: ...@@ -2,5 +2,5 @@ def inc(x: int) -> int:
return x + 1 return x + 1
def test_answer(): def test_answer() -> None:
assert inc(3) ==4 assert inc(3) ==4
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment