Skip to content

Commit abcfc67

Browse files
denniskempincrosvm LUCI
authored and
crosvm LUCI
committed
Add python configs for consistency between IDE and CI
Also adds settings to .vscode/settings.json to use the correct formatter and type checking settings out of the box. VSCode uses pyright and health-check uses mypy. They do not always agree unfortunately, mypy is a little more lenient. Unfortunately pyright is hard to get working with our scripts that have no file extension. BUG=b:242605601 TEST=./tools/health-check Change-Id: Iaef4ac6f61613e7dda409d5e717102ea9adefe82 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3833699 Commit-Queue: Dennis Kempin <[email protected]> Tested-by: Dennis Kempin <[email protected]> Reviewed-by: Daniel Verkamp <[email protected]>
1 parent c89cf4b commit abcfc67

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ target/
66
**/*.pyc
77
lcov.info
88
.idea
9-
.vscode
109
.envrc
10+
.vscode/*
11+
!.vscode/settings.json

.vscode/settings.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
// Python
3+
"python.formatting.provider": "black",
4+
"python.analysis.typeCheckingMode": "strict"
5+
}

mypy.ini

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[mypy]
2+
python_version = 3.9
3+
mypy_path = tools

pyproject.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[tool.black]
2+
line-length = 100
3+
4+
[tool.pyright]
5+
include = ["tools"]
6+
exclude = ["target"]
7+
ignore = ["infra", "tools/windows", "tools/contrib"]
8+
pythonVersion = "3.9"
9+
pythonPlatform = "Linux"
10+
typeCheckingMode = "strict"
11+

tools/health-check

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ def check_python_tests(context: CheckContext):
1818

1919
def check_python_types(context: CheckContext):
2020
"Run mypy on all python files to type-check."
21-
mypy = cmd("mypy --pretty --color-output").env("MYPY_FORCE_COLOR", "1").env("MYPYPATH", "tools")
21+
mypy = cmd("mypy --pretty --color-output").env("MYPY_FORCE_COLOR", "1")
2222
parallel(*mypy.foreach(context.all_files)).fg()
2323

2424

2525
def check_python_format(context: CheckContext):
26-
black = cmd("black", "--line-length 100", "--check" if not context.fix else "")
26+
black = cmd("black", "--check" if not context.fix else "")
2727
parallel(*black.foreach(context.modified_files)).fg()
2828

2929

0 commit comments

Comments
 (0)