Skip to content

Commit 4bbac78

Browse files
committed
chore: enable mypy with baseline
Related: orsinium-labs/mypy-baseline#30
1 parent 6aae554 commit 4bbac78

39 files changed

+379
-5
lines changed

.pre-commit-config.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
---
2+
# cspell: ignore gitmoji
23
ci:
34
# We rely on renovate to update it but there is no way to fully disable it
45
# https://github.com/pre-commit-ci/issues/issues/83
56
autoupdate_schedule: quarterly
67
skip:
78
- ansible-lint
9+
- uv-lock
810
- renovate-config-validator # container limits
911
repos:
12+
- repo: https://github.com/commitizen-tools/commitizen
13+
rev: v4.8.3
14+
hooks:
15+
- id: commitizen
16+
additional_dependencies:
17+
- cz-conventional-gitmoji
18+
- id: commitizen-branch
19+
stages:
20+
- pre-push
21+
- repo: https://github.com/astral-sh/uv-pre-commit
22+
rev: 0.8.13
23+
hooks:
24+
- id: uv-sync
25+
- id: uv-lock
26+
name: "deps: upgrade via uv sync --upgrade"
27+
alias: deps
28+
args: ["--upgrade"]
29+
stages: [manual]
30+
- id: uv-lock
31+
alias: lock
1032
- repo: https://github.com/renovatebot/pre-commit-hooks
1133
rev: 41.91.1
1234
hooks:
@@ -69,6 +91,16 @@ repos:
6991
- id: ruff-check
7092
args: ["--fix"]
7193
alias: ruff
94+
# Uncomment once https://github.com/orsinium-labs/mypy-baseline/pull/30 is released
95+
# - repo: https://github.com/pre-commit/mirrors-mypy
96+
# rev: v1.17.1
97+
# hooks:
98+
# - id: mypy
99+
# pass_filenames: false
100+
# additional_dependencies:
101+
# - mypy-baseline
102+
# - types-toml
103+
# keep at bottom as these are slower
72104
- repo: https://github.com/ansible/ansible-lint
73105
rev: v25.8.2
74106
hooks:

mypy-baseline.txt

Lines changed: 294 additions & 0 deletions
Large diffs are not rendered by default.

pyproject.toml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ build-backend = "setuptools.build_meta"
1111
dev = [
1212
"bindep>=2.13.0",
1313
"molecule[test]>=25.1.0",
14+
"mypy>=1.17.1",
15+
"mypy-baseline>=0.7.3",
1416
"pytest-helpers-namespace>=2019.1.8"
1517
]
1618
docker = [
@@ -23,7 +25,8 @@ lint = [
2325
"molecule>=25.7.0",
2426
"pre-commit>=4.1",
2527
"pre-commit-uv>=4.1.4",
26-
"toml>=0.10.2"
28+
"toml>=0.10.2",
29+
"types-toml>=0.10.8.20240310"
2730
]
2831
pkg = [
2932
"build>=0.9",
@@ -122,16 +125,36 @@ changelog = "https://github.com/ansible-community/molecule-plugins/releases"
122125
[tool.codespell]
123126
skip = "uv.lock"
124127

128+
[tool.mypy]
129+
files = "."
130+
color_output = true
131+
error_summary = true
132+
# explicit_package_bases = true
133+
namespace_packages = false
134+
exclude = [
135+
".ansible",
136+
".cache",
137+
".tox",
138+
".venv",
139+
"node_modules",
140+
"build",
141+
"dist",
142+
"site",
143+
"scenarios"
144+
]
145+
strict = true
146+
125147
[tool.pytest.ini_options]
126148
addopts = "-v -rxXs --doctest-modules --durations 10 -p no:pytest_ansible"
127149
doctest_optionflags = "ALLOW_UNICODE ELLIPSIS"
128150
junit_suite_name = "molecule_test_suite"
129151
norecursedirs = ["dist", "doc", "build", ".tox", ".eggs", "src", "test/*/scenarios", "test/*/resources"]
130152

131153
[tool.ruff]
132-
target-version = "py39"
154+
target-version = "py310"
133155
# Same as Black.
134156
line-length = 88
157+
unsafe-fixes = true
135158
lint.ignore = [
136159
"E501", # we use black
137160
# we deliberately ignore these:
@@ -201,6 +224,8 @@ runner = "uv-venv-lock-runner"
201224
skip_install = false
202225
commands_pre = []
203226
commands = [
227+
# move inside a pre-commit hook once https://github.com/orsinium-labs/mypy-baseline/pull/30 is released
228+
["bash", "-c", "mypy | mypy-baseline filter --hide-stats --allow-unsynced && mypy | mypy-baseline sync --sort-baseline"],
204229
["pre-commit", "run", "-a"],
205230
["bash", "{tox_root}/tools/generate-templates.sh"],
206231
["rm", "-rf", "test/roles"]
File renamed without changes.

test/openstack/test_func.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import subprocess
77
from pathlib import Path
88

9+
import openstack
910
import pytest
1011

11-
import openstack
1212
from conftest import change_dir_to
1313
from molecule import logger
1414
from molecule.app import get_app
File renamed without changes.

test/vagrant_plugin/functional/__init__.py

Whitespace-only changes.
File renamed without changes.

test/vagrant-plugin/functional/test_func.py renamed to test/vagrant_plugin/functional/test_func.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ def is_vagrant_supported() -> bool:
3838
"""Return True if vagrant is installed and current platform is supported."""
3939
if not shutil.which("vagrant"):
4040
return False
41-
if not (platform.machine() == "arm64" and platform.system() == "Darwin"):
42-
return True
41+
return bool(not (platform.machine() == "arm64" and platform.system() == "Darwin"))
4342

4443

4544
@pytest.mark.skipif(
File renamed without changes.

0 commit comments

Comments
 (0)