replace flake8 by ruff

This commit is contained in:
Thomas Waldmann 2023-09-04 22:15:42 +02:00
parent 1fd8b52f6b
commit 98796a2f0d
No known key found for this signature in database
GPG Key ID: 243ACFA951F78E01
7 changed files with 68 additions and 53 deletions

View File

@ -32,18 +32,11 @@ jobs:
lint:
runs-on: ubuntu-22.04
timeout-minutes: 10
timeout-minutes: 2
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Lint with flake8
run: |
pip install flake8
flake8 src scripts conftest.py
- uses: chartboost/ruff-action@v1
linux:

View File

@ -3,8 +3,7 @@ repos:
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
files: '(src|scripts|conftest.py)'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
hooks:
- id: ruff

View File

@ -12,7 +12,8 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
import sys, os
import sys
import os
sys.path.insert(0, os.path.abspath("../src"))

View File

@ -12,3 +12,58 @@ write_to_template = "__version__ = version = {version!r}\n"
[tool.black]
line-length = 120
skip-magic-trailing-comma = true
[tool.ruff]
line-length = 120
target-version = "py39"
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["E", "F"]
# for reference ...
# E402 module level import not at top
# E501 line too long
# F401 import unused
# F405 undefined or defined from star imports
# F811 redef of unused var
# borg code style guidelines:
# Ignoring E203 due to https://github.com/PyCQA/pycodestyle/issues/373
ignore = ["E203", "F405", "E402"]
# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
unfixable = []
# Exclude a variety of commonly ignored directories.
exclude = [
".cache",
".eggs",
".git",
".git-rewrite",
".idea",
".mypy_cache",
".ruff_cache",
".tox",
"build",
"dist",
]
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# Code style violation exceptions:
# please note that the values are adjusted so that they do not cause failures
# with existing code. if you want to change them, you should first fix all
# ruff failures that appear with your change.
[tool.ruff.per-file-ignores]
"setup_docs.py" = ["E501"]
"src/borg/archive.py" = ["E501"]
"src/borg/archiver/help_cmd.py" = ["E501"]
"src/borg/cache.py" = ["E501"]
"src/borg/helpers/__init__.py" = ["F401"]
"src/borg/platform/__init__.py" = ["F401"]
"src/borg/testsuite/archiver/disk_full.py" = ["F811"]
"src/borg/testsuite/archiver/return_codes.py" = ["F811"]
"src/borg/testsuite/benchmark.py" = ["F811"]
"src/borg/testsuite/platform.py" = ["F811"]

View File

@ -74,39 +74,6 @@ python_files = testsuite/*.py
markers =
allow_cache_wipe
[flake8]
# for reference ...
# E402 module level import not at top
# E501 line too long
# F401 import unused
# F405 undefined or defined from star imports
# F811 redef of unused var
# #### Pick either W503, or W504 - latest recommendation from pep8 is to ignore W503
# W503 line break before binary operator
# W504 line break after binary operator
# borg code style guidelines:
# Ignoring E203 due to https://github.com/PyCQA/pycodestyle/issues/373
ignore = W503, E203, F405, E402
# Code style violation exceptions:
# please note that the values are adjusted so that they do not cause failures
# with existing code. if you want to change them, you should first fix all
# flake8 failures that appear with your change.
per_file_ignores =
src/borg/archive.py:E501
src/borg/archiver/help_cmd.py:E501
src/borg/cache.py:E501
src/borg/helpers/__init__.py:F401
src/borg/platform/__init__.py:F401
src/borg/testsuite/archiver/disk_full.py:F811
src/borg/testsuite/archiver/return_codes.py:F811
src/borg/testsuite/benchmark.py:F811
src/borg/testsuite/platform.py:F811
max_line_length = 120
exclude = build,dist,.git,.idea,.cache,.tox
[mypy]
python_version = 3.9
strict_optional = False

View File

@ -1,4 +1,4 @@
from typing import FrozenSet, Set, NamedTuple, Tuple, Mapping, Dict, List, Iterator, Callable, Any, Optional
from typing import Set, NamedTuple, Tuple, Mapping, Dict, List, Iterator, Callable, Any, Optional
from .helpers import StableDict
@ -96,7 +96,7 @@ class ArchiveItem(PropDict):
def items(self, val: List) -> None: ...
@property
def item_ptrs(self) -> List: ...
@items.setter
@item_ptrs.setter
def item_ptrs(self, val: List) -> None: ...
class ChunkListEntry(NamedTuple):

View File

@ -28,13 +28,13 @@ passenv = *
passenv = * # needed by tox4, so env vars are visible for building borg
[testenv:flake8]
[testenv:ruff]
skip_sdist=true
skip_install=true
changedir =
deps =
flake8
commands = flake8 src scripts conftest.py
ruff
commands = ruff check .
[testenv:mypy]
changedir =