Skip to content

Commit b403e35

Browse files
Python linting (#528)
Co-authored-by: Alexander Lanin <[email protected]> Co-authored-by: Maximilian Sören Pollak <[email protected]>
1 parent 0096ebe commit b403e35

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

.devcontainer/devcontainer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"usernamehw.errorlens",
1111
"hediet.vscode-drawio",
1212
"swyddfa.esbonio",
13-
"lextudio.restructuredtext"
13+
"lextudio.restructuredtext",
14+
"charliermarsh.ruff"
1415
]
1516
}
1617
}

.vscode/extensions.json

+3
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111

1212
// ErrorLens highlights errors and warnings in your code / docs
1313
"usernamehw.errorlens",
14+
15+
// Linting and formatting for Python (LSP via ruff server)
16+
"charliermarsh.ruff",
1417
]
1518
}

.vscode/settings.json

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
"editor.rulers": [
3535
79
3636
],
37+
// Opinionated option for the future:
38+
// "editor.formatOnSave": true,
39+
"editor.codeActionsOnSave": {
40+
"source.sortImports": "explicit"
41+
},
42+
"editor.defaultFormatter": "charliermarsh.ruff",
3743
},
3844

3945
// Markdown Settings

pyproject.toml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This file is at the root level, as it applies to all Python code,
2+
# not only to docs or to tools.
3+
4+
[tool.pyright]
5+
typeCheckingMode = "standard"
6+
pythonVersion = "3.12" # Keep in sync with MODULE.bazel
7+
8+
exclude = [
9+
"**/__pycache__",
10+
"**/.*",
11+
"bazel-*",
12+
]
13+
14+
[tool.ruff]
15+
target-version = "py312"
16+
extend-exclude = [
17+
"__pycache__",
18+
".*",
19+
"bazel-*",
20+
]
21+
22+
# Selected rules for clean code, readability, and bug prevention
23+
lint.select = [
24+
"E", # pycodestyle (PEP8)
25+
"F", # pyflakes (undefined vars, unused imports)
26+
"I", # isort (import sorting)
27+
"B", # flake8-bugbear (likely bugs)
28+
"C90", # mccabe (complexity checks)
29+
"UP", # pyupgrade (modern Python 3.12+ features)
30+
"SIM", # flake8-simplify (simplifies code patterns)
31+
"RET" # flake8-return (consistent return statements)
32+
]
33+
34+
lint.ignore = [
35+
# Rules we want to ignore go in here.
36+
# Always provide a comment explaining why.
37+
]

0 commit comments

Comments
 (0)