Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Python-CI-Template
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonathan Windgassen
Python-CI-Template
Commits
61f367fc
Commit
61f367fc
authored
Jan 21, 2022
by
Christian Witzler
Committed by
Jonathan Windgassen
Jan 21, 2022
Browse files
Options
Downloads
Patches
Plain Diff
don't allow errors in mypy check
parent
4010b7ec
Branches
Branches containing commit
No related tags found
1 merge request
!7
don't allow errors in mypy check
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
ci/mypy.sh
+6
-11
6 additions, 11 deletions
ci/mypy.sh
src/main.py
+3
-1
3 additions, 1 deletion
src/main.py
src/test_sample.py
+1
-1
1 addition, 1 deletion
src/test_sample.py
with
11 additions
and
13 deletions
.gitignore
+
1
−
0
View file @
61f367fc
__pycache__
__pycache__
.coverage
.coverage
.ipynb_checkpoints
This diff is collapsed.
Click to expand it.
ci/mypy.sh
+
6
−
11
View file @
61f367fc
#!/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
...
...
This diff is collapsed.
Click to expand it.
src/main.py
+
3
−
1
View file @
61f367fc
from
typing
import
Any
class
Test
:
class
Test
:
def
__init__
(
self
,
arg
:
a
ny
):
def
__init__
(
self
,
arg
:
A
ny
)
->
None
:
"""
Test.
"""
"""
Test.
"""
print
(
arg
)
print
(
arg
)
...
...
This diff is collapsed.
Click to expand it.
src/test_sample.py
+
1
−
1
View file @
61f367fc
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment