Skip to content

Commit

Permalink
Merge pull request #7808 from ThomasWaldmann/ruff-master
Browse files Browse the repository at this point in the history
replace flake8 by ruff
  • Loading branch information
ThomasWaldmann committed Sep 4, 2023
2 parents 1fd8b52 + 98796a2 commit 5cce0d7
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 53 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
9 changes: 4 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

Expand Down
55 changes: 55 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
33 changes: 0 additions & 33 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/borg/item.pyi
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 5cce0d7

Please sign in to comment.