Skip to content

Commit 0fb76b6

Browse files
authored
Use Ruff for linting and formatting. By @SAMAD101 (#1980)
1 parent 4aea368 commit 0fb76b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+101
-73
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ b6a24debb78b953117a3f637db18942f370a4b85
33

44
# Run pre-commit after adding ruff
55
24e1dd5c561bc3da972e41e6fd61961f12a2fc9f
6+
7+
# Apply ruff sort settings
8+
ba9f1bd3d77dbd0b9efeb1f2f91c743b97ec558e

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ jobs:
2222
python-version: 3.11
2323
pre-commit: true
2424

25-
- name: Test formatting with Flake8, ruff and Black
25+
- name: Test formatting with ruff
2626
shell: bash
27-
run: make lint
27+
run: pre-commit run --all-files --show-diff-on-failure
2828

2929
prepare-matrix:
3030
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,19 @@ repos:
2929
- id: requirements-txt-fixer
3030

3131
- repo: https://github.com/charliermarsh/ruff-pre-commit
32-
rev: "v0.0.257"
32+
rev: v0.7.0
3333
hooks:
34+
# Run the linter.
3435
- id: ruff
35-
args: [--fix, --exit-non-zero-on-fix]
36+
# Run the formatter.
37+
- id: ruff-format
3638

3739
# format python files
38-
- repo: https://github.com/psf/black
39-
rev: 22.12.0
40-
hooks:
41-
- id: black
42-
files: ^(src/vorta/|tests)
40+
# - repo: https://github.com/psf/black
41+
# rev: 22.12.0
42+
# hooks:
43+
# - id: black
44+
# files: ^(src/vorta/|tests)
4345

4446
# # run black on code embedded in docstrings
4547
# - repo: https://github.com/asottile/blacken-docs
@@ -56,12 +58,6 @@ repos:
5658
# py39,
5759
# ]
5860

59-
# check pep8 conformity using flake8
60-
- repo: https://github.com/PyCQA/flake8
61-
rev: 6.0.0
62-
hooks:
63-
- id: flake8
64-
6561
# configuration for the pre-commit.ci bot
6662
# only relevant when actually using the bot
6763
ci:

bin/.gitkeep

Whitespace-only changes.

package/fix_app_qt_folder_names_for_codesign.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import sys
1212
from pathlib import Path
1313
from typing import Generator, List, Optional
14+
1415
from macholib.MachO import MachO
1516

1617

pyproject.toml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
[tool.black]
2-
line-length = 120
3-
skip-string-normalization = true
4-
target-version = ['py39']
5-
include = "(src/vorta/|tests).*.py$"
6-
71
[build-system]
82
requires = ["setuptools"]
93
build-backend = "setuptools.build_meta"
104

115
[tool.ruff]
12-
select = ["T", "I"]
13-
exclude = ["package"]
14-
fixable = ["I"]
6+
line-length = 120
7+
# exclude = ["package", "build", "dist", ".git", ".idea", ".cache", ".tox", ".eggs", "./src/vorta/__init__.py", ".direnv", "env"]
8+
include = ["src/**/*.py", "tests/**/*.py"]
9+
10+
[tool.ruff.lint]
11+
select = [
12+
"E", # Error
13+
"F", # pyflakes
14+
"I", # isort
15+
"W", # Warning
16+
"YTT", # flake8-2020
17+
]
18+
ignore = [
19+
"F401",
20+
]
21+
22+
[tool.ruff.format]
23+
quote-style = "preserve"

requirements.d/dev.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
black==22.*
21
coverage
3-
flake8
42
macholib
53
nox
64
pkgconfig

setup.cfg

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,8 @@ source = vorta
7272
omit = tests/*
7373
relative_files = true
7474

75-
[flake8]
76-
ignore =
77-
max-line-length = 120
78-
extend-ignore = E203,E121,E123,E126,E226,E24,E704,W503,W504
79-
exclude =
80-
build,dist,.git,.idea,.cache,.tox,.eggs,
81-
./src/vorta/__init__.py,.direnv,env
82-
8375
[tox:tox]
84-
envlist = py36,py37,py38,flake8
76+
envlist = py36,py37,py38
8577
skip_missing_interpreters = true
8678

8779
[testenv]
@@ -92,10 +84,10 @@ deps =
9284
commands=pytest
9385
passenv = DISPLAY
9486

95-
[testenv:flake8]
87+
[testenv:ruff]
9688
deps =
97-
flake8
98-
commands=flake8 src tests
89+
ruff
90+
commands=ruff check src tests
9991

10092
[pycodestyle]
10193
max_line_length = 120

src/vorta/assets/exclusion_presets/browsers.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
],
136136
"tags": ["application:firefox", "type:browser", "os:linux"],
137137
"author": "Divi, Renner0E"
138-
}
138+
},
139139
{
140140
"name": "Mozilla Firefox Snap cache and config files",
141141
"slug": "firefox-snap-cache",

src/vorta/autostart.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def open_app_at_startup(enabled=True):
3131
while on Linux it adds a .desktop file at ~/.config/autostart
3232
"""
3333
if sys.platform == 'darwin':
34-
3534
url = NSURL.alloc().initFileURLWithPath_(APP_PATH)
3635
login_items = LSSharedFileListCreate(kCFAllocatorDefault, kLSSharedFileListSessionLoginItems, None)
3736
props = NSDictionary.dictionaryWithObject_forKey_(True, kLSSharedFileListItemHidden)

0 commit comments

Comments
 (0)