From f0a5a36275eb8951c230289bfa81eb0e1292b2f7 Mon Sep 17 00:00:00 2001 From: Divyansh Singh Date: Tue, 21 Mar 2023 14:35:11 +0530 Subject: [PATCH] ci: Add ruff including print checks Adds ruff replacing isort. Ruff comes with all flake8 rules and additional rules for print statements. * .github/workflows/test.yml : Replace isort with ruff in comment * .editorconfig : Update `yml` config to apply to all yaml files. * Makefile (lint): Run ruff, remove isort * .pre-commit-config.yaml : Remove isort, run ruff * pyproject.toml : Configure ruff. Remove isort config. * requirements.d/dev.txt : Add ruff, remove isort * setup.cfg : Extend flake8 file ignore * src/vorta/__main__.py : Add *noqa* for print statement. --- .editorconfig | 2 +- .github/workflows/test.yml | 2 +- .pre-commit-config.yaml | 12 ++++++------ Makefile | 2 +- pyproject.toml | 13 +++++-------- requirements.d/dev.txt | 4 ++-- setup.cfg | 2 +- src/vorta/__main__.py | 2 +- 8 files changed, 18 insertions(+), 21 deletions(-) diff --git a/.editorconfig b/.editorconfig index 04575d6d..d958a8ca 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,5 +13,5 @@ trim_trailing_whitespace = true [Makefile] indent_style = tab -[.github/**.yml] +[**.{yml,yaml}] indent_size = 2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ac5a0dd9..54e74e43 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ jobs: run: | pip install . pip install -r requirements.d/dev.txt - - name: Test formatting with Flake8, isort and Black + - name: Test formatting with Flake8, ruff and Black run: make lint # - name: Run PyLint (info only) # run: pylint --rcfile=setup.cfg src --exit-zero diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4acb82f2..61afc63e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,6 +28,12 @@ repos: # sort requirements.txt files - id: requirements-txt-fixer + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: "v0.0.257" + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix] + # format python files - repo: https://github.com/psf/black rev: 22.12.0 @@ -35,12 +41,6 @@ repos: - id: black files: ^(src/vorta/|tests) - # sort python imports - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - # # run black on code embedded in docstrings # - repo: https://github.com/asottile/blacken-docs # rev: v1.12.1 diff --git a/Makefile b/Makefile index d1d793e2..362f9e50 100644 --- a/Makefile +++ b/Makefile @@ -58,8 +58,8 @@ flatpak-install: translations-to-qm lint: flake8 - isort --check-only . black --check . + ruff check . test: pytest --cov=vorta diff --git a/pyproject.toml b/pyproject.toml index 6e8c4574..b7ddd68e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,14 +4,11 @@ skip-string-normalization = true target-version = ['py39'] include = "(src/vorta/|tests).*.py$" -[tool.isort] -profile = "black" -line_length = 120 -skip_gitignore = true -multi_line_output = 3 -lines_between_sections = 0 -src_paths = ["src", "tests"] - [build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" + +[tool.ruff] +select = ["T", "I"] +exclude = ["package"] +fixable = ["I"] diff --git a/requirements.d/dev.txt b/requirements.d/dev.txt index 3c9c38f1..239dfbff 100644 --- a/requirements.d/dev.txt +++ b/requirements.d/dev.txt @@ -1,9 +1,8 @@ -pre-commit black==22.* coverage flake8 -isort macholib +pre-commit pyinstaller pylint pytest @@ -11,6 +10,7 @@ pytest-cov pytest-faulthandler pytest-mock pytest-qt +ruff tox twine wheel diff --git a/setup.cfg b/setup.cfg index 76187557..edddb2f1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -77,7 +77,7 @@ max-line-length = 120 extend-ignore = E203,E121,E123,E126,E226,E24,E704,W503,W504 exclude = build,dist,.git,.idea,.cache,.tox,.eggs, - ./src/vorta/__init__.py,.direnv + ./src/vorta/__init__.py,.direnv,env [tox:tox] envlist = py36,py37,py38,flake8 diff --git a/src/vorta/__main__.py b/src/vorta/__main__.py index 40f146bc..3cba250f 100644 --- a/src/vorta/__main__.py +++ b/src/vorta/__main__.py @@ -47,7 +47,7 @@ def main(): want_background = getattr(args, 'daemonize', False) if want_version: - print(f"Vorta {__version__}") + print(f"Vorta {__version__}") # noqa: T201 sys.exit() if want_background: