Skip to content

Commit

Permalink
Lint and format code with Ruff
Browse files Browse the repository at this point in the history
This replaces Flake8

In previous configuration:
 - "B" errors were supposed to be caught but
flake8-bugbear was not installed so it couldn't work.
 - "B9" seemed to be unrequired because already taken into account with "B"
 - "T4" corresponds to flake8-mypy but it was not installed.
  • Loading branch information
pgiraud committed Nov 27, 2024
1 parent 5c45afe commit 60596b4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 31 deletions.
17 changes: 0 additions & 17 deletions .flake8

This file was deleted.

10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
repos:
- repo: local
hooks:
- id: ruff
name: ruff
entry: ruff check
language: system
types: [python]
- id: ruff-format
name: ruff-format
entry: ruff format
language: system
types: [python]
- id: pyupgrade
name: pyupgrade
entry: pyupgrade --exit-zero-even-if-changed
Expand Down
21 changes: 21 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
target-version = "py39"
exclude = [
".eggs",
".tox",
".venv",
".cache",
]

[lint]
extend-select = [
"E", # pycodestyle errors
"F", # pyflakes
"I", # isort
"W", # pycodestyle warnings
]
ignore = [
"E501", # line too long
]

[lint.isort]
known-first-party = ["pgtoolkit"]
9 changes: 1 addition & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ dev = [
"pgtoolkit[lint,typing,test,doc]",
]
lint = [
"black",
"ruff",
"check-manifest",
"flake8",
"isort",
"pyupgrade",
]
typing = [
"mypy",
Expand All @@ -57,10 +54,6 @@ doc = [
Repository = "https://github.com/dalibo/pgtoolkit"
Documentation = "https://pgtoolkit.readthedocs.io/"

[tool.isort]
profile = "black"
multi_line_output = 3

[tool.setuptools.packages.find]
where = ["."]

Expand Down
8 changes: 2 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ isolated_build = true

[testenv:lint]
commands=
flake8
black --check --diff .
isort --check --diff .
ruff check
ruff format --check
pre-commit run --all-files --show-diff-on-failure pyupgrade
check-manifest
deps =
flake8
black
check-manifest
isort
pre-commit
pyupgrade
skip_install = true
Expand Down

0 comments on commit 60596b4

Please sign in to comment.