Skip to content

Commit 7e393c6

Browse files
committed
KIT-4745 introduce ruff initial commit
1 parent 42c2544 commit 7e393c6

10 files changed

Lines changed: 112 additions & 69 deletions

.devcontainer/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ FROM mcr.microsoft.com/devcontainers/python:3.12-bookworm
33

44
# Uninstall pre-installed formatting and linting tools
55
# They would conflict with our pinned versions
6-
RUN pipx uninstall flake8
76
RUN pipx uninstall mypy

.devcontainer/devcontainer.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,15 @@
88
"vscode": {
99
"settings": {
1010
"python.pythonPath": "/usr/local/bin/python",
11-
"python.defaultInterpreterPath": "/usr/local/bin/python",
12-
"python.languageServer": "Pylance",
13-
"flake8.path": [
14-
"/usr/local/py-utils/bin/bandit",
15-
"/usr/local/py-utils/bin/pydocstyle"
16-
],
17-
"flake8.importStrategy": "fromEnvironment"
11+
"python.defaultInterpreterPath": "/usr/local/bin/python"
1812
},
1913
"extensions": [
2014
"AykutSarac.jsoncrack-vscode",
15+
"charliermarsh.ruff",
2116
"eamodio.gitlens",
2217
"Gruntfuggly.todo-tree",
2318
"matangover.mypy",
24-
"ms-python.flake8",
25-
"ms-python.isort",
2619
"ms-python.mypy-type-checker",
27-
"ms-python.pylint",
2820
"ms-python.python",
2921
"ms-python.vscode-pylance",
3022
"njpwerner.autodocstring",

.flake8

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

.github/flake8-error-problem-matcher.json

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

.github/flake8-warning-problem-matcher.json

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

.pylintrc

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

.vscode/settings.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"files.trimTrailingWhitespace": true,
1010
"files.exclude": {
1111
".coverage": true,
12-
".flake8": true,
1312
".gitattributes": true,
1413
".gitignore": true,
1514
".idea": true,
@@ -29,8 +28,8 @@
2928
"python.testing.pytestEnabled": true,
3029
"python.testing.unittestEnabled": false,
3130
"[python]": {
32-
"editor.defaultFormatter": "ms-python.black-formatter",
33-
"editor.formatOnSave": true
31+
"editor.formatOnSave": true,
32+
"editor.defaultFormatter": "charliermarsh.ruff"
3433
},
3534
"python.analysis.diagnosticSeverityOverrides": {
3635
"reportPrivateUsage": "information",

.vscode/tasks.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@
1414
{
1515
"label": "Lint",
1616
"type": "shell",
17-
"command": "flake8 . --count --statistics; mypy .",
17+
"command": "ruff check; mypy .",
18+
"group": "test",
19+
"presentation": {
20+
"reveal": "always",
21+
"panel": "new"
22+
}
23+
},
24+
{
25+
"label": "Format all",
26+
"type": "shell",
27+
"command": "ruff format",
1828
"group": "test",
1929
"presentation": {
2030
"reveal": "always",

pyproject.toml

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ pandas = "*"
1616
[tool.poetry.group.dev.dependencies]
1717
build = "*"
1818
coverage-lcov = "*"
19-
flake8-bandit = "*"
20-
flake8-pydocstyle = "*"
2119
mypy = "*"
2220
parameterized = "*"
2321
pytest = "*"
@@ -27,3 +25,100 @@ types-mock = "*"
2725
[build-system]
2826
requires = ["setuptools>=61.0"]
2927
build-backend = "setuptools.build_meta"
28+
29+
[tool.ruff]
30+
line-length = 120
31+
# Exclude a variety of commonly ignored directories.
32+
exclude = [
33+
".bzr",
34+
".direnv",
35+
".eggs",
36+
".env",
37+
".git",
38+
".git-rewrite",
39+
".hg",
40+
".ipynb_checkpoints",
41+
".mypy_cache",
42+
".nox",
43+
".pants.d",
44+
".pyenv",
45+
".pytest_cache",
46+
".pytype",
47+
".ruff_cache",
48+
".svn",
49+
".tox",
50+
".venv",
51+
".vscode",
52+
"__pypackages__",
53+
"_build",
54+
"buck-out",
55+
"build",
56+
"dist",
57+
"node_modules",
58+
"site-packages",
59+
"venv",
60+
]
61+
62+
63+
[tool.ruff.format]
64+
quote-style = "double"
65+
66+
[tool.ruff.lint.pylint]
67+
max-nested-blocks = 6
68+
max-args = 8
69+
max-positional-args = 8
70+
71+
[tool.ruff.lint]
72+
preview = true
73+
select = [
74+
"ASYNC", # Async: https://docs.astral.sh/ruff/rules/#flake8-async-async
75+
"B", # Flake8 Bugbear: https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
76+
"C901", # complex-structure
77+
"D", # Docstyle: https://docs.astral.sh/ruff/rules/#pydocstyle-d
78+
"DOC", # Pydoclint: https://docs.astral.sh/ruff/rules/#pydoclint-doc
79+
"E", # Errors: https://docs.astral.sh/ruff/rules/#error-e
80+
"F", # Flakes: https://docs.astral.sh/ruff/rules/#pyflakes-f
81+
"G", # Logging format: https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
82+
"I", # Isort: https://docs.astral.sh/ruff/rules/#isort-i
83+
"ISC001", # single-line-implicit-string-concatenation
84+
"N", # Naming: https://docs.astral.sh/ruff/rules/#pep8-naming-n
85+
"PL", # Pylint: https://docs.astral.sh/ruff/rules/#pylint-pl
86+
"Q", # Quotes: https://docs.astral.sh/ruff/rules/#flake8-quotes-q
87+
"RET", # Return: https://docs.astral.sh/ruff/rules/#flake8-return-ret
88+
"SIM", # Simplify: https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
89+
"SLF", # Private member access: https://docs.astral.sh/ruff/rules/#flake8-self-slf
90+
"UP", # Upgrade: https://docs.astral.sh/ruff/rules/#pyupgrade-up
91+
"W", # Warnings: https://docs.astral.sh/ruff/rules/#warning-w
92+
]
93+
ignore = [
94+
"B017", # Do not assert blind exception: `Exception`
95+
"D100", # undocumented-public-module
96+
"D101", # undocumented-public-class
97+
"D102", # undocumented-public-method
98+
"D103", # undocumented-public-function
99+
"D104", # undocumented-public-package
100+
"D105", # undocumented-magic-method
101+
"D106", # undocumented-public-nested-class
102+
"D107", # undocumented-public-init
103+
"D203", # one blank line required before class docstring
104+
"D213", # multi-line summary starts on second line
105+
"DOC201", # docstring-missing-returns
106+
"DOC501", # docstring-missing-exception"
107+
"ISC001", # single-line-implicit-string-concatenation
108+
"N818", # error-suffix-on-exception-name
109+
"N999", # invalid-module-name
110+
]
111+
112+
[tool.ruff.lint.per-file-ignores]
113+
"tests/**" = [
114+
"D400", # first-line-should-end-with-period
115+
"D415", # first-line-should-end-with
116+
"PLC2701", # import-private-name
117+
"PLR2004", # magic-value-comparison
118+
"PLR6301", # static method
119+
"PLR0904", # too-many-public-methods
120+
"SLF001", # private-member-access
121+
"N802", # invalid-function-name
122+
"N818", # invalid-class-name
123+
"N999", # invalid-module-name
124+
]

requirements-dev.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
-r requirements.txt
22
coverage-lcov
33
build
4-
flake8-bandit
5-
flake8-pydocstyle
64
mypy
75
parameterized
86
pytest

0 commit comments

Comments
 (0)