From b339f53bb45081e6cca68bdfaf20453e92f81027 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Tue, 23 May 2023 01:06:14 +0200 Subject: [PATCH] Add isort and ruff linter Both linters are pretty common among modern python code bases. The isort tool provides stable sorting and grouping, as well as pruning of unused imports. Ruff is a modern linter, that is very fast due to being written in rust. It can detect many common issues in a python codebase. Removes the pylint dev requirement, since ruff replaces it. --- .github/workflows/pull_request.yml | 14 ++++++++++---- pyproject.toml | 5 +++++ requirements-dev.txt | 3 ++- 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 pyproject.toml diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 1c1d2cd76..7e38c3b99 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -70,11 +70,17 @@ jobs: python-version: ${{ env.DEFAULT_PYTHON }} - name: Install requirements run: | - pip install pip - pip install -r requirements-dev.txt - - name: Lint + python3 -m pip install -U pip + python3 -m pip install -r requirements-dev.txt + - name: Check black run: | - python3 -m black frigate --check + black --check --diff frigate migrations docker *.py + - name: Check isort + run: | + isort --check --diff frigate migrations docker *.py + - name: Check ruff + run: | + ruff check frigate migrations docker *.py python_tests: runs-on: ubuntu-latest diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..e3ef3faf5 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +[tool.isort] +profile = "black" + +[tool.ruff] +ignore = ["E501"] \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt index 29f004455..0acd15ae4 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,3 @@ -pylint == 2.17.* black == 23.3.* +isort +ruff