Skip to content

Commit 2b5eb4b

Browse files
authored
switch to ruff as linter (#113)
* switch to ruff as linter * fix licenses and error out in scripts * align scripts with template * add timeout * fix tests, reset changes in generated files * tests * fix
1 parent 5504400 commit 2b5eb4b

32 files changed

+147
-291
lines changed

.devcontainer/devcontainer.json

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,21 @@
1313
"vscode": {
1414
// Set *default* container specific settings.json values on container create.
1515
"settings": {
16-
"python.pythonPath": "/usr/bin/python3",
1716
"python.defaultInterpreterPath": "/usr/bin/python3",
18-
"python.disableInstallationCheck": true,
19-
"python.linting.enabled": true,
20-
"python.formatting.provider": "black",
21-
"python.linting.banditEnabled": true,
22-
"python.linting.flake8Enabled": true,
23-
"editor.defaultFormatter": "ms-python.black-formatter",
17+
"python.analysis.typeCheckingMode": "basic",
18+
// Strong Type Checker
19+
"mypy.enabled": true,
20+
"mypy.runUsingActiveInterpreter": true,
21+
"python.testing.unittestEnabled": false,
22+
"python.testing.pytestEnabled": true,
23+
"[python]": {
24+
"editor.formatOnSave": true,
25+
"editor.codeActionsOnSave": {
26+
"source.fixAll": true,
27+
"source.organizeImports": true
28+
},
29+
"editor.defaultFormatter": "charliermarsh.ruff"
30+
},
2431
"terminal.integrated.defaultProfile.linux": "zsh",
2532
"terminal.integrated.profiles.linux": {
2633
"zsh": {
@@ -31,17 +38,15 @@
3138
// Add the IDs of extensions you want installed when the container is created.
3239
"extensions": [
3340
"ms-python.python",
34-
"dbaeumer.vscode-eslint",
3541
"ms-azuretools.vscode-dapr",
3642
"ms-azuretools.vscode-docker",
3743
"rpdswtk.vsmqtt",
3844
"dotjoshjohnson.xml",
3945
"ms-kubernetes-tools.vscode-kubernetes-tools",
4046
"matangover.mypy",
4147
"anweber.vscode-httpyac",
42-
"ms-python.black-formatter",
43-
"ms-python.isort",
44-
"ms-python.flake8"
48+
"ms-python.mypy-type-checker",
49+
"charliermarsh.ruff"
4550
]
4651
}
4752
},

.pre-commit-config.yaml

Lines changed: 7 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ repos:
3434
.*_pb2_grpc.py
3535
)$
3636
- id: check-yaml
37-
- id: check-toml
3837
- id: check-added-large-files
3938
exclude: >
4039
(?x)^(
@@ -45,60 +44,16 @@ repos:
4544
)$
4645
- id: check-merge-conflict
4746

48-
- repo: https://github.com/PyCQA/isort
49-
rev: 5.12.0
47+
- repo: https://github.com/astral-sh/ruff-pre-commit
48+
rev: v0.1.13
5049
hooks:
51-
- id: isort
52-
exclude: >
53-
(?x)^(
54-
.*_pb2.py|
55-
.*_pb2.pyi|
56-
.*_pb2_grpc.py|
57-
examples/.*|
58-
.project-creation/.skeleton/.*
59-
)$
60-
61-
- repo: https://github.com/psf/black
62-
rev: 23.9.1
63-
hooks:
64-
- id: black
65-
exclude: >
66-
(?x)^(
67-
.*_pb2.py|
68-
.*_pb2.pyi|
69-
.*_pb2_grpc.py|
70-
examples/.*
71-
)$
72-
73-
- repo: https://github.com/PyCQA/flake8
74-
rev: 6.1.0
75-
hooks:
76-
- id: flake8
77-
exclude: >
78-
(?x)^(
79-
.*_pb2.py|
80-
.*_pb2.pyi|
81-
.*_pb2_grpc.py
82-
)$
83-
additional_dependencies:
84-
- flake8-bugbear
85-
- flake8-unused-arguments
86-
87-
- repo: https://github.com/PyCQA/bandit
88-
rev: 1.7.5
89-
hooks:
90-
- id: bandit
91-
exclude: >
92-
(?x)^(
93-
.*_pb2.py|
94-
.*_pb2.pyi|
95-
.*_pb2_grpc.py
96-
)$
97-
args: ["--skip=B101"]
98-
types_or: [python]
50+
- id: ruff
51+
args: [--fix, --exclude, "*_pb2.py,*_pb2.pyi,*_pb2_grpc.py,*.log"]
52+
- id: ruff-format
53+
args: [--exclude, "*_pb2.py,*_pb2.pyi,*_pb2_grpc.py,*.log"]
9954

10055
- repo: https://github.com/pre-commit/mirrors-mypy
101-
rev: v1.5.1
56+
rev: v1.8.0
10257
hooks:
10358
- id: mypy
10459
exclude: >
@@ -111,17 +66,6 @@ repos:
11166
language: system
11267
pass_filenames: false
11368

114-
- repo: https://github.com/pycqa/pydocstyle
115-
rev: 6.3.0
116-
hooks:
117-
- id: pydocstyle
118-
exclude: >
119-
(?x)^(
120-
.*_pb2.py|
121-
.*_pb2.pyi|
122-
.*_pb2_grpc.py
123-
)$
124-
12569
- repo: https://github.com/Lucas-C/pre-commit-hooks
12670
rev: v1.5.4
12771
hooks:

.project-creation/templates/setup.cfg

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
[flake8]
2-
max-line-length = 88
3-
max-complexity = 18
4-
select = B,C,E,F,W,T4,B9,B950
5-
61
[mypy]
72
python_version = 3.10
83
warn_unused_configs = True
@@ -18,12 +13,3 @@ files =
1813

1914
[mypy-vehicle_model.proto.*]
2015
ignore_errors = True
21-
22-
[pydocstyle]
23-
match = '(?!test_).*\.py'
24-
25-
[isort]
26-
profile = black
27-
28-
[tool.bandit]
29-
skips = ["B101"]

.vscode/scripts/ensure-dapr.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# under the License.
1313
#
1414
# SPDX-License-Identifier: Apache-2.0
15+
set -e
1516

1617
if [ $1 != "DAPR" ]; then
1718
echo "Don't install dapr ..."

.vscode/scripts/exec-check.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# under the License.
1313
#
1414
# SPDX-License-Identifier: Apache-2.0
15+
set -e
1516

1617
if [[ "$#" -eq 1 ]]; then
1718
tput setaf 1; echo "ERROR: To execute script, use VSCODE Tasks: [CTRL+SHIFT+P -> Tasks: Run Tasks -> $1]."

.vscode/scripts/run-feedercan.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# under the License.
1313
#
1414
# SPDX-License-Identifier: Apache-2.0
15+
set -e
1516

1617
echo "#######################################################"
1718
echo "### Running FeederCan ###"

.vscode/scripts/run-hvacservice.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# under the License.
1313
#
1414
# SPDX-License-Identifier: Apache-2.0
15+
set -e
1516

1617
echo "#######################################################"
1718
echo "### Running HVAC Service ###"

.vscode/scripts/run-mosquitto.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# under the License.
1313
#
1414
# SPDX-License-Identifier: Apache-2.0
15+
set -e
1516

1617
echo "#######################################################"
1718
echo "### Running MQTT Broker ###"
@@ -30,4 +31,4 @@ then
3031
docker container stop $RUNNING_CONTAINER
3132
fi
3233

33-
docker run -p 1883:1883 -p 9001:9001 $MOSQUITTO_IMAGE:$MOSQUITTO_TAG mosquitto -c /mosquitto-no-auth.conf
34+
docker run --rm --init --name mqtt-broker -p 1883:1883 -p 9001:9001 --network host $MOSQUITTO_IMAGE:$MOSQUITTO_TAG mosquitto -c /mosquitto-no-auth.conf

.vscode/scripts/run-seatservice.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# under the License.
1313
#
1414
# SPDX-License-Identifier: Apache-2.0
15+
set -e
1516

1617
echo "#######################################################"
1718
echo "### Running Seat Service ###"

.vscode/scripts/run-vehicledatabroker-cli.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# under the License.
1313
#
1414
# SPDX-License-Identifier: Apache-2.0
15+
set -e
1516

1617
echo "#######################################################"
1718
echo "### Running VehicleDataBroker CLI ###"

0 commit comments

Comments
 (0)