Skip to content

Commit

Permalink
ci: Add ruff including print checks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
diivi authored and real-yfprojects committed May 1, 2023
1 parent 4d65912 commit f0a5a36
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ trim_trailing_whitespace = true
[Makefile]
indent_style = tab

[.github/**.yml]
[**.{yml,yaml}]
indent_size = 2
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ 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
hooks:
- 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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ flatpak-install: translations-to-qm

lint:
flake8
isort --check-only .
black --check .
ruff check .

test:
pytest --cov=vorta
Expand Down
13 changes: 5 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions requirements.d/dev.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
pre-commit
black==22.*
coverage
flake8
isort
macholib
pre-commit
pyinstaller
pylint
pytest
pytest-cov
pytest-faulthandler
pytest-mock
pytest-qt
ruff
tox
twine
wheel
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/vorta/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def exception_handler(type, value, tb):
want_background = getattr(args, 'daemonize', False)

if want_version:
print(f"Vorta {__version__}")
print(f"Vorta {__version__}") # noqa: T201
sys.exit()

if want_background:
Expand Down

0 comments on commit f0a5a36

Please sign in to comment.