Skip to content

Commit 1e17d8b

Browse files
authored
Merge pull request #4800 from barnabasdomozi/mypy_ci
Integrate mypy into CI
2 parents 1b412ad + 80a2fb3 commit 1e17d8b

13 files changed

Lines changed: 62 additions & 58 deletions

File tree

.github/workflows/codechecker_master_analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/checkout@v2
1818
- uses: actions/setup-python@v4
1919
with:
20-
python-version: '3.9'
20+
python-version: '3.10'
2121
- name: Install dependencies
2222
run: |
2323
pip install $(grep -iE "pylint|pycodestyle" analyzer/requirements_py/dev/requirements.txt)

.github/workflows/codechecker_pr_analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v2
1515
- uses: actions/setup-python@v4
1616
with:
17-
python-version: '3.9'
17+
python-version: '3.10'
1818
- name: Install dependencies
1919
run: |
2020
pip install $(grep -iE "pylint|pycodestyle" analyzer/requirements_py/dev/requirements.txt)

.github/workflows/config_coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- uses: actions/checkout@v3
3232
- uses: actions/setup-python@v4
3333
with:
34-
python-version: '3.9'
34+
python-version: '3.10'
3535
- name: "Install dependencies"
3636
run: |
3737
# Some packages, e.g. build-essential and curl are available

.github/workflows/pypi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/checkout@v2
1818
- uses: actions/setup-python@v4
1919
with:
20-
python-version: '3.9'
20+
python-version: '3.10'
2121
- uses: actions/setup-node@v1
2222
with:
2323
node-version: '16.x'
@@ -63,7 +63,7 @@ jobs:
6363
steps:
6464
- uses: actions/setup-python@v4
6565
with:
66-
python-version: '3.9'
66+
python-version: '3.10'
6767

6868
- uses: actions/download-artifact@master
6969
with:

.github/workflows/test.yml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,30 @@ jobs:
2020
- uses: actions/checkout@v2
2121
- uses: actions/setup-python@v4
2222
with:
23-
python-version: '3.9'
23+
python-version: '3.10'
2424
- name: Install dependencies
2525
run: |
2626
pip install $(grep -iE "pylint|pycodestyle" analyzer/requirements_py/dev/requirements.txt)
2727
- name: Run pycodestyle & pylint
2828
run: make -k pycodestyle pylint
2929

30+
type-checker:
31+
name: Type checker (mypy)
32+
33+
runs-on: ubuntu-24.04
34+
35+
steps:
36+
- uses: actions/checkout@v2
37+
- uses: actions/setup-python@v4
38+
with:
39+
python-version: '3.10'
40+
- name: Create venv-dev
41+
run: |
42+
make venv_dev
43+
- name: Run mypy
44+
run: |
45+
make mypy
46+
3047
tools:
3148
name: Tools (report-converter, etc.)
3249
runs-on: ubuntu-24.04
@@ -35,7 +52,7 @@ jobs:
3552
- uses: actions/checkout@v2
3653
- uses: actions/setup-python@v4
3754
with:
38-
python-version: '3.9'
55+
python-version: '3.10'
3956
- name: Setup Bazel
4057
uses: abhinavsingh/setup-bazel@v3
4158
with:
@@ -91,7 +108,7 @@ jobs:
91108
- uses: actions/checkout@v2
92109
- uses: actions/setup-python@v4
93110
with:
94-
python-version: '3.9'
111+
python-version: '3.10'
95112

96113
- name: Install dependencies
97114
run: sh .github/workflows/install-deps.sh
@@ -109,25 +126,6 @@ jobs:
109126
working-directory: analyzer
110127
run: make test_unit_cov
111128

112-
common:
113-
name: Common libraries
114-
runs-on: ubuntu-24.04
115-
116-
steps:
117-
- uses: actions/checkout@v2
118-
- uses: actions/setup-python@v4
119-
with:
120-
python-version: '3.9'
121-
122-
- name: Install requirements
123-
working-directory: codechecker_common
124-
run: |
125-
pip install -r requirements_py/dev/requirements.txt
126-
127-
- name: Run mypy tests
128-
working-directory: codechecker_common/tests
129-
run: make mypy
130-
131129
web:
132130
name: Web
133131
runs-on: ubuntu-24.04
@@ -153,7 +151,7 @@ jobs:
153151
- uses: actions/checkout@v2
154152
- uses: actions/setup-python@v4
155153
with:
156-
python-version: '3.9'
154+
python-version: '3.10'
157155

158156
- name: Install dependencies
159157
run: sh .github/workflows/install-deps.sh
@@ -198,7 +196,7 @@ jobs:
198196
- uses: actions/checkout@v2
199197
- uses: actions/setup-python@v4
200198
with:
201-
python-version: '3.9'
199+
python-version: '3.10'
202200
- uses: actions/setup-node@v1
203201
with:
204202
node-version: '16.x'

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ pycodestyle:
179179
pycodestyle_in_env:
180180
$(ACTIVATE_DEV_VENV) && $(PYCODE_CMD)
181181

182+
mypy:
183+
$(ACTIVATE_DEV_VENV) && mypy --config-file pyproject.toml
184+
182185
test: test_analyzer test_web
183186

184187
test_in_env: test_analyzer_in_env test_web_in_env

codechecker_common/compatibility/multiprocessing.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@
1313
# pylint: disable=no-name-in-module
1414
# pylint: disable=unused-import
1515
if sys.platform in ["darwin", "win32"]:
16-
from multiprocess import \
17-
Pipe, Pool, Process, \
18-
Queue, \
19-
Value, \
16+
from multiprocess import ( # type: ignore
17+
Pipe, Pool, Process,
18+
Queue,
19+
Value,
2020
cpu_count
21-
from multiprocess.managers import SyncManager
21+
)
22+
from multiprocess.managers import SyncManager # type: ignore
2223
else:
2324
from concurrent.futures import ProcessPoolExecutor as Pool
24-
from multiprocessing import \
25-
Pipe, \
26-
Process, \
27-
Queue, \
28-
Value, \
25+
from multiprocessing import (
26+
Pipe,
27+
Process,
28+
Queue,
29+
Value,
2930
cpu_count
31+
)
3032
from multiprocessing.managers import SyncManager
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
portalocker~=3.0
22
coverage<=5.5.0
3-
mypy<=1.7.1
3+
mypy~=1.19.0
44
PyYAML~=6.0
55
types-PyYAML~=6.0
66
setuptools~=80.0

codechecker_common/review_status_handler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def __report_matches_rule(self, report: Report, rule: dict):
184184
report.checker_name != rule['filters']['checker_name']:
185185
return False
186186

187-
if 'report_hash' in rule['filters'] and not \
187+
if 'report_hash' in rule['filters'] and report.report_hash and not \
188188
report.report_hash.startswith(rule['filters']['report_hash']):
189189
return False
190190

@@ -211,7 +211,7 @@ def get_review_status(self, report: Report) -> SourceReviewStatus:
211211
return review_status
212212

213213
# 3. Return "unreviewed" otherwise.
214-
return SourceReviewStatus(bug_hash=report.report_hash)
214+
return SourceReviewStatus(bug_hash=report.report_hash or "")
215215

216216
def set_review_status_config(self, config_file):
217217
"""
@@ -289,7 +289,7 @@ def get_review_status_from_config(
289289
message=rule['actions']['reason']
290290
.encode(encoding='utf-8', errors='ignore')
291291
if 'reason' in rule['actions'] else b'',
292-
bug_hash=report.report_hash,
292+
bug_hash=report.report_hash or "",
293293
in_source=True)
294294

295295
return None
@@ -343,7 +343,7 @@ def get_review_status_from_source(
343343
return SourceReviewStatus(
344344
status=status,
345345
message=message.encode('utf-8'),
346-
bug_hash=report.report_hash,
346+
bug_hash=report.report_hash or "",
347347
in_source=True)
348348

349349
if len(src_comment_data) > 1:

codechecker_common/tests/Makefile

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)