Skip to content

Commit

Permalink
use ruff as linter (#220)
Browse files Browse the repository at this point in the history
* use ruff as linter

* fix review findings
  • Loading branch information
MP91 authored Jan 22, 2024
1 parent b72e716 commit 5d534e2
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 77 deletions.
21 changes: 8 additions & 13 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,19 @@
"mypy.targets": [
"app"
],
// Security Linter
"python.linting.banditEnabled": true,
"python.linting.banditArgs": [
"-c setup.cfg"
],
// Style Checker for Python Docs
"python.linting.pydocstyleEnabled": true,
"python.analysis.extraPaths": [
"./proto",
"./src/vehicle_model"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"[python]": {
// Style Formatter
"editor.defaultFormatter": "ms-python.black-formatter"
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
},
"editor.defaultFormatter": "charliermarsh.ruff"
},
"vs-kubernetes": {
"vscode-kubernetes.kubectl-path.linux": "/usr/local/bin/kubectl",
Expand Down Expand Up @@ -85,10 +82,8 @@
"ms-kubernetes-tools.vscode-kubernetes-tools",
"matangover.mypy",
"augustocdias.tasks-shell-input",
"ms-python.isort",
"ms-python.flake8",
"ms-python.black-formatter",
"ms-python.mypy-type-checker"
"ms-python.mypy-type-checker",
"charliermarsh.ruff"
]
}
},
Expand Down
48 changes: 7 additions & 41 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -31,55 +31,21 @@ repos:
)$
- id: check-merge-conflict

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.13
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
exclude: >
(?x)^(
.*_pb2.py|
.*_pb2.pyi|
.*_pb2_grpc.py
)$
additional_dependencies:
- flake8-bugbear
- flake8-unused-arguments

- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
args: ["--skip=B101"]
types_or: [python]
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.5.1"
rev: "v1.8.0"
hooks:
- id: mypy
args: [app]
language: system
pass_filenames: false

- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle

- repo: https://github.com/gruntwork-io/pre-commit
rev: v0.1.22
hooks:
- id: helmlint

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
Expand Down
4 changes: 2 additions & 2 deletions .velocitas.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
{
"name": "devenv-runtimes",
"version": "v2.2.3"
"version": "v2.2.4"
},
{
"name": "devenv-github-workflows",
Expand All @@ -14,7 +14,7 @@
},
{
"name": "devenv-devcontainer-setup",
"version": "v1.4.5"
"version": "v1.4.6"
}
],
"variables": {
Expand Down
11 changes: 7 additions & 4 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ SPDX-License-Identifier: Apache-2.0
| Kubectl | https://github.com/kubernetes/kubectl/blob/master/LICENSE |
| K9S | https://github.com/derailed/k9s/blob/master/LICENSE |
| Redis | https://redis.com/legal/licenses/ |
| Mosquitto | https://github.com/eclipse/mosquitto/blob/master/LICENSE.txt |
| Mosquitto | https://github.com/eclipse/mosquitto/blob/master/LICENSE.txt |

### Development
| Software | License |
| :------: | :------------------------------------------------------------------: |
| GRPC | https://github.com/grpc/grpc/blob/master/LICENSE |
| Software | License |
| :------: | :------------------------------------------------------------------: |
| GRPC | https://github.com/grpc/grpc/blob/master/LICENSE |
| Pre-Commit | https://github.com/pre-commit/pre-commit/blob/main/LICENSE |
| Mypy | https://github.com/python/mypy/blob/master/LICENSE |
| Ruff | https://github.com/astral-sh/ruff/main/LICENSE |

### Further 3rd party licenses used in project
* [Auto-generated 3rd party licenses](./NOTICE-3RD-PARTY-CONTENT.md)
Expand Down
3 changes: 2 additions & 1 deletion app/tests/unit/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ async def test_for_publish_to_topic():
VehicleApp, "publish_mqtt_event", new_callable=mock.AsyncMock, return_value=-1
):
response = await VehicleApp.publish_mqtt_event(
str("sampleTopic"), get_sample_response_data() # type: ignore
str("sampleTopic"), # type: ignore
get_sample_response_data(),
)

print(f"Received response: {response}")
Expand Down
16 changes: 0 additions & 16 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
[flake8]
max-line-length = 88
max-complexity = 18
extend-ignore = E203,W503
# More information about aligning flake8 and black configs can be found at https://github.com/psf/black/blob/06ccb88bf2bd35a4dc5d591bb296b5b299d07323/docs/guides/using_black_with_other_tools.md#configuration
select = B,C,E,W,F,T4,B9,B950

[mypy]
python_version = 3.10
warn_unused_configs = True
Expand All @@ -20,12 +13,3 @@ files =

[mypy-vehicle_model.proto.*]
ignore_errors = True

[pydocstyle]
match = '(?!test_).*\.py'

[isort]
profile = black

[tool.bandit]
skips = ["B101"]

0 comments on commit 5d534e2

Please sign in to comment.