Skip to content

Commit e0cbb10

Browse files
authored
Merge pull request #49 from ianlewis/41-feature-add-mypy-check
feat: add mypy type checker
2 parents 8489bfa + 05805d6 commit e0cbb10

File tree

7 files changed

+125
-3
lines changed

7 files changed

+125
-3
lines changed

.github/workflows/pull_request.tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ jobs:
6060
markdownlint:
6161
uses: ./.github/workflows/workflow_call.markdownlint.yml
6262

63+
mypy:
64+
uses: ./.github/workflows/workflow_call.mypy.yml
65+
6366
renovate-config-validator:
6467
uses: ./.github/workflows/workflow_call.renovate-config-validator.yml
6568

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2024 Ian Lewis
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: mypy
16+
17+
on:
18+
workflow_call:
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
mypy:
25+
name: mypy
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
29+
with:
30+
submodules: true
31+
persist-credentials: false
32+
33+
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
34+
with:
35+
python-version-file: ".python-version"
36+
37+
- run: make mypy

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ yaml-format: node_modules/.installed ## Format YAML files.
303303
#####################################################################
304304

305305
.PHONY: lint
306-
lint: actionlint checkmake commitlint fixme format-check markdownlint renovate-config-validator ruff textlint yamllint zizmor ## Run all linters.
306+
lint: actionlint checkmake commitlint fixme format-check markdownlint mypy renovate-config-validator ruff textlint yamllint zizmor ## Run all linters.
307307

308308
.PHONY: actionlint
309309
actionlint: $(AQUA_ROOT_DIR)/.installed ## Runs the actionlint linter.
@@ -479,6 +479,21 @@ markdownlint: node_modules/.installed $(AQUA_ROOT_DIR)/.installed ## Runs the ma
479479
$${files}; \
480480
fi
481481

482+
.PHONY: mypy
483+
mypy: .venv/.installed ## Runs the mypy type checker.
484+
@# bash \
485+
files=$$( \
486+
git ls-files --deduplicate \
487+
'*.py' \
488+
| while IFS='' read -r f; do [ -f "$${f}" ] && echo "$${f}" || true; done \
489+
); \
490+
if [ "$${files}" == "" ]; then \
491+
exit 0; \
492+
fi; \
493+
${REPO_ROOT}/.venv/bin/mypy \
494+
--config-file mypy.ini \
495+
$${files}
496+
482497
.PHONY: renovate-config-validator
483498
renovate-config-validator: node_modules/.installed ## Validate Renovate configuration.
484499
@# bash \

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ Linting
144144
fixme Check for outstanding FIXMEs.
145145
format-check Check that files are properly formatted.
146146
markdownlint Runs the markdownlint linter.
147+
mypy Runs the mypy type checker.
147148
renovate-config-validator Validate Renovate configuration.
148149
ruff Runs the ruff linter.
149150
textlint Runs the textlint linter.
@@ -269,6 +270,7 @@ to achieve the highest Tier and score as possible.
269270
- [ ] `format-check / format-check`
270271
- [ ] `fixme / fixme`
271272
- [ ] `markdownlint / markdownlint`
273+
- [ ] `mypy / mypy`
272274
- [ ] `renovate-config-validator / renovate-config-validator`
273275
- [ ] `ruff / ruff`
274276
- [ ] `textlint / textlint`

main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
"""A sample Python application."""
1818

19-
import io
2019
import sys
20+
import typing
2121

2222

23-
def main(out: io.TextIOBase) -> None:
23+
def main(out: typing.TextIO) -> None:
2424
"""Execute the application."""
2525
out.write("Hello, World!")
2626

mypy.ini

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2025 Ian Lewis
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# TODO: Relax mypy settings as needed.
16+
# mypy it set to strict mode. This is a good starting point for type checking, but
17+
# you may want to relax some of these settings as you see fit.
18+
# See https://mypy.readthedocs.io/en/stable/config_file
19+
[mypy]
20+
strict = True

requirements-dev.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,48 @@ coverage==7.10.7 \
213213
--hash=sha256:f7941f6f2fe6dd6807a1208737b8a0cbcf1cc6d7b07d24998ad2d63590868260 \
214214
--hash=sha256:fc04cc7a3db33664e0c2d10eb8990ff6b3536f6842c9590ae8da4c614b9ed05a \
215215
--hash=sha256:fff7b9c3f19957020cac546c70025331113d2e61537f6e2441bc7657913de7d3
216+
mypy==1.18.2 \
217+
--hash=sha256:01199871b6110a2ce984bde85acd481232d17413868c9807e95c1b0739a58914 \
218+
--hash=sha256:030c52d0ea8144e721e49b1f68391e39553d7451f0c3f8a7565b59e19fcb608b \
219+
--hash=sha256:06a398102a5f203d7477b2923dda3634c36727fa5c237d8f859ef90c42a9924b \
220+
--hash=sha256:07b8b0f580ca6d289e69209ec9d3911b4a26e5abfde32228a288eb79df129fcc \
221+
--hash=sha256:0e2785a84b34a72ba55fb5daf079a1003a34c05b22238da94fcae2bbe46f3544 \
222+
--hash=sha256:1331eb7fd110d60c24999893320967594ff84c38ac6d19e0a76c5fd809a84c86 \
223+
--hash=sha256:1379451880512ffce14505493bd9fe469e0697543717298242574882cf8cdb8d \
224+
--hash=sha256:20c02215a080e3a2be3aa50506c67242df1c151eaba0dcbc1e4e557922a26075 \
225+
--hash=sha256:22a1748707dd62b58d2ae53562ffc4d7f8bcc727e8ac7cbc69c053ddc874d47e \
226+
--hash=sha256:22f27105f1525ec024b5c630c0b9f36d5c1cc4d447d61fe51ff4bd60633f47ac \
227+
--hash=sha256:25a9c8fb67b00599f839cf472713f54249a62efd53a54b565eb61956a7e3296b \
228+
--hash=sha256:33eca32dd124b29400c31d7cf784e795b050ace0e1f91b8dc035672725617e34 \
229+
--hash=sha256:3ca30b50a51e7ba93b00422e486cbb124f1c56a535e20eff7b2d6ab72b3b2e37 \
230+
--hash=sha256:448acd386266989ef11662ce3c8011fd2a7b632e0ec7d61a98edd8e27472225b \
231+
--hash=sha256:592ec214750bc00741af1f80cbf96b5013d81486b7bb24cb052382c19e40b428 \
232+
--hash=sha256:5d6c838e831a062f5f29d11c9057c6009f60cb294fea33a98422688181fe2893 \
233+
--hash=sha256:62f0e1e988ad41c2a110edde6c398383a889d95b36b3e60bcf155f5164c4fdce \
234+
--hash=sha256:664dc726e67fa54e14536f6e1224bcfce1d9e5ac02426d2326e2bb4e081d1ce8 \
235+
--hash=sha256:6ca1e64b24a700ab5ce10133f7ccd956a04715463d30498e64ea8715236f9c9c \
236+
--hash=sha256:749b5f83198f1ca64345603118a6f01a4e99ad4bf9d103ddc5a3200cc4614adf \
237+
--hash=sha256:776bb00de1778caf4db739c6e83919c1d85a448f71979b6a0edd774ea8399341 \
238+
--hash=sha256:7a780ca61fc239e4865968ebc5240bb3bf610ef59ac398de9a7421b54e4a207e \
239+
--hash=sha256:7ab28cc197f1dd77a67e1c6f35cd1f8e8b73ed2217e4fc005f9e6a504e46e7ba \
240+
--hash=sha256:7fb95f97199ea11769ebe3638c29b550b5221e997c63b14ef93d2e971606ebed \
241+
--hash=sha256:807d9315ab9d464125aa9fcf6d84fde6e1dc67da0b6f80e7405506b8ac72bc7f \
242+
--hash=sha256:8795a039bab805ff0c1dfdb8cd3344642c2b99b8e439d057aba30850b8d3423d \
243+
--hash=sha256:a2afc0fa0b0e91b4599ddfe0f91e2c26c2b5a5ab263737e998d6817874c5f7c8 \
244+
--hash=sha256:a3c47adf30d65e89b2dcd2fa32f3aeb5e94ca970d2c15fcb25e297871c8e4764 \
245+
--hash=sha256:a431a6f1ef14cf8c144c6b14793a23ec4eae3db28277c358136e79d7d062f62d \
246+
--hash=sha256:aa5e07ac1a60a253445797e42b8b2963c9675563a94f11291ab40718b016a7a0 \
247+
--hash=sha256:c1eab0cf6294dafe397c261a75f96dc2c31bffe3b944faa24db5def4e2b0f77c \
248+
--hash=sha256:c2b9c7e284ee20e7598d6f42e13ca40b4928e6957ed6813d1ab6348aa3f47133 \
249+
--hash=sha256:c3ad2afadd1e9fea5cf99a45a822346971ede8685cc581ed9cd4d42eaf940986 \
250+
--hash=sha256:d6985ed057513e344e43a26cc1cd815c7a94602fb6a3130a34798625bc2f07b6 \
251+
--hash=sha256:d8068d0afe682c7c4897c0f7ce84ea77f6de953262b12d07038f4d296d547074 \
252+
--hash=sha256:d924eef3795cc89fecf6bedc6ed32b33ac13e8321344f6ddbf8ee89f706c05cb \
253+
--hash=sha256:ed4482847168439651d3feee5833ccedbf6657e964572706a2adb1f7fa4dfe2e \
254+
--hash=sha256:f9e171c465ad3901dc652643ee4bffa8e9fef4d7d0eece23b428908c77a76a66
255+
typing-extensions==4.15.0 \
256+
--hash=sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466 \
257+
--hash=sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548
258+
mypy-extensions==1.1.0 \
259+
--hash=sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505 \
260+
--hash=sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558

0 commit comments

Comments
 (0)