Skip to content

Commit b9ddbbd

Browse files
committed
Add mypy type checking to CI (#226)
Signed-off-by: AravCS <aravshah927@gmail.com>
1 parent d316aaf commit b9ddbbd

5 files changed

Lines changed: 89 additions & 1 deletion

File tree

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ jobs:
5050
# - name: Validate code format
5151
# run: make check
5252

53+
- name: Check types
54+
run: make mypy
55+
5356
- name: Run tests
5457
run: make test
5558
env:

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ webtest:
131131
@echo "-> Run web tests"
132132
${ACTIVATE} ${PYTHON_EXE} -m pytest -vvs -m "webtest"
133133

134+
mypy:
135+
@echo "-> Run mypy type checking"
136+
@${ACTIVATE} mypy
137+
134138
bump:
135139
@echo "-> Bump the version"
136140
bin/bumpver update --no-fetch --patch
@@ -148,4 +152,4 @@ docker-images:
148152
@mkdir -p dist/
149153
@docker save postgres vulnerablecode_vulnerablecode nginx | gzip > dist/vulnerablecode-images-`git describe --tags`.tar.gz
150154

151-
.PHONY: virtualenv conf dev envfile install check valid isort clean migrate postgres sqlite run test bump docs docker-images
155+
.PHONY: virtualenv conf dev envfile install check valid isort clean migrate postgres sqlite run test mypy bump docs docker-images

mypy.ini

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[mypy]
2+
ignore_missing_imports = True
3+
follow_imports = silent
4+
explicit_package_bases = True
5+
namespace_packages = True
6+
7+
check_untyped_defs = True
8+
9+
warn_unused_configs = True
10+
warn_redundant_casts = True
11+
warn_unused_ignores = True
12+
13+
strict_equality = True
14+
warn_return_any = True
15+
16+
files =
17+
# fetch and parse vulnerability data from upstream sources
18+
vulnerabilities/importers/debian_oval.py,
19+
vulnerabilities/importers/epss.py,
20+
vulnerabilities/importers/project_kb_msr2019.py,
21+
vulnerabilities/importers/redhat.py,
22+
vulnerabilities/importers/suse_scores.py,
23+
vulnerabilities/importers/ubuntu_usn.py,
24+
vulnerabilities/importers/xen.py,
25+
26+
# shared logic that transforms advisory data after import
27+
vulnerabilities/pipes/apache_kafka.py,
28+
vulnerabilities/pipes/export.py,
29+
vulnerabilities/pipes/extractcode_utils.py,
30+
vulnerabilities/pipes/federatedcode.py,
31+
vulnerabilities/pipes/risk_score.py,
32+
33+
# public REST API (v2): the project's external contract
34+
vulnerabilities/api_v2.py,
35+
36+
# CLI entry points for imports, improvers, and scheduling
37+
vulnerabilities/management/commands/create_api_user.py,
38+
vulnerabilities/management/commands/import.py,
39+
vulnerabilities/management/commands/improve.py,
40+
vulnerabilities/management/commands/purl2cpe.py,
41+
vulnerabilities/management/commands/run_scheduler.py,
42+
43+
# how vulnerabilities are scored, related, and scheduled
44+
vulnerabilities/risk.py,
45+
vulnerabilities/references.py,
46+
vulnerabilities/schedules.py,
47+
vulnerabilities/improvers/vulnerability_status.py,
48+
vulnerabilities/pipelines/v2_importers/collect_fix_commits.py,
49+
50+
# forms, API pagination, and rate limiting
51+
vulnerabilities/forms.py,
52+
vulnerabilities/pagination.py,
53+
vulnerabilities/throttling.py,
54+
55+
# supporting utilities and admin config
56+
vulnerabilities/admin.py,
57+
vulnerabilities/rpm_utils.py,
58+
vulnerabilities/weight_config.py,
59+
60+
# fully clean directories: request middleware and template tags
61+
vulnerabilities/middleware,
62+
vulnerabilities/templatetags,
63+
64+
# Django project configuration
65+
vulnerablecode/__init__.py,
66+
vulnerablecode/context_processors.py,
67+
vulnerablecode/urls.py,
68+
vulnerablecode/wsgi.py,
69+
70+
# shared library for deterministic advisory IDs
71+
aboutcode,
72+
73+
# bundled CLI tool for cross-checking vulnerability sources
74+
vulntotal/__init__.py,
75+
vulntotal/vulntotal_utils.py,
76+
vulntotal/ecosystem,
77+
vulntotal/datasources/safetydb.py,
78+
vulntotal/tests,

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ MarkupSafe==3.0.3
8080
matplotlib-inline==0.2.1
8181
mdurl==0.1.2
8282
more-itertools==10.8.0
83+
mypy==2.1.0
8384
mypy_extensions==1.1.0
8485
nh3==0.3.4
8586
packageurl-python==0.17.6

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ dev =
127127
# Tests
128128
pytest==7.1.1
129129
pytest-django==4.5.2
130+
# Type checking
131+
mypy==2.1.0
130132

131133
# misc
132134
ipython==8.10.0

0 commit comments

Comments
 (0)