Skip to content

Commit

Permalink
ci(precommit): Replace flake8 with Ruff
Browse files Browse the repository at this point in the history
These opinionated bugbear rules are not implemented in Ruff yet:
- B950 (line too long), using equivalent: E501.
- B902 (invalid first arg for method), using equivalent: N804, N805
See: astral-sh/ruff#2954

These pycodestyle rules are not implemented in Ruff yet and have no
equivalent rules:
- E303 (too many blank lines),
- E302 (Expected 2 blank lines, found 0)
- E301 (Expected 1 blank line, found 0)
Previously ignored for "pydavinci/wrappers/settings/components.py".
Since they don't exist, we don't need to ignore them, but this will apply
package wide. Black should handle formatting these correctly anyway.
  • Loading branch information
in03 committed Mar 13, 2023
1 parent 0438d4f commit 1fe258d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 20 deletions.
7 changes: 0 additions & 7 deletions .flake8

This file was deleted.

24 changes: 11 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,19 @@ repos:
hooks:
- id: black
# By default, this ignores pyi files, though black supports them
# Flake8 also supports pre-commit natively (same author)
- repo: https://github.com/pycqa/isort
rev: 5.10.1
# Ruff supports flake8, bugbear rules
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.254'
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black"]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
args: ['--ignore=F403,E501,B950,E266']
additional_dependencies: [flake8-bugbear, pep8-naming]
exclude: ^(docs/.*|tools/.*|tests/.*)$
- id: ruff

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.940 # Use the sha / tag you want to point at
hooks:
- id: mypy
exclude: ^tests/

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ dependencies = [
"typing_extensions>=4.1.1",
]

[project.optional-dependencies]
dev = [
"mypy",
"black",
"flake8",
"pre-commit",
]
[project.urls]
Homepage = "https://github.com/pedrolabonia/pydavinci"
Source = "https://github.com/pedrolabonia/pydavinci"
Expand Down
34 changes: 34 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

# Enable flake8-bugbear (`B`) rules.
select = [
"B",
"C",
"F",
"W",
"TCH",
"B9",
]

# Never enforce `E501` (line length violations).
ignore = [
"E501",
"F403",
"E501",
"F403",
"E501",
"N805",
"N804",
"W293",
]

src = ["src"]

# Avoid trying to fix flake8-bugbear (`B`) violations.
unfixable = ["B"]

[mccabe]
max-complexity = 18

# Ignore `E402` (import violations) in all `__init__.py` files.
[per-file-ignores]
"__init__.py" = ["E402"]

0 comments on commit 1fe258d

Please sign in to comment.