Skip to content

Commit

Permalink
[pre-commit] Configure ruff to sort import
Browse files Browse the repository at this point in the history
I'm not sure if ruff handle first party / third parties, but it's good enough for the doc
  • Loading branch information
Pierre-Sassoulas committed Mar 10, 2023
1 parent 0d26e3c commit 5c51bc5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repos:
rev: "v0.0.254"
hooks:
- id: ruff
name: line-length-doc
name: ruff-doc
files: doc/data/messages
args: ["--config", "doc/data/ruff.toml"]
- repo: https://github.com/Pierre-Sassoulas/copyright_notice_precommit
Expand All @@ -45,7 +45,7 @@ repos:
rev: 5.12.0
hooks:
- id: isort
exclude: doc/data/messages/(r/reimported|w/wrong-import-order|u/ungrouped-imports|m/misplaced-future|m/multiple-imports)/bad.py
exclude: doc/data/messages/
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
Expand Down
10 changes: 9 additions & 1 deletion doc/data/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@ ignore = []
# Reading ease is drastically reduced on read the doc after 103 chars
# (Because of horizontal scrolling)
line-length = 103
select = ["E501"]
select = ["E501", "I"]


[per-file-ignores]
"doc/data/messages/r/reimported/bad.py" = ["I"]
"doc/data/messages/w/wrong-import-order/bad.py" = ["I"]
"doc/data/messages/u/ungrouped-imports/bad.py" = ["I"]
"doc/data/messages/m/misplaced-future/bad.py" = ["I"]
"doc/data/messages/m/multiple-imports/bad.py" = ["I"]
26 changes: 21 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,27 @@ module = [
]

[tool.ruff]
select = ["E", "F", "W", "B"]
ignore = [
"B905", # Not enforced previousely
]
fixable = ["E", "F", "W", "B"]

# ruff is less lenient than pylint and does not make any exceptions
# (for docstrings, strings and comments in particular).
line-length = 115

select = [
"E", # pycodestyle
"F", # pyflakes
"W", # pycodestyle
"B", # bugbear
"I", # isort
]

ignore = [
"B905", # `zip()` without an explicit `strict=` parameter
]

fixable = [
"E", # pycodestyle
"F", # pyflakes
"W", # pycodestyle
"B", # bugbear
"I", # isort
]
2 changes: 1 addition & 1 deletion requirements_test_pre_commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pre-commit~=3.1;python_version>='3.8'
bandit==1.7.4
black==23.1.0
flake8==6.0.0;python_version>='3.8'
ruff
ruff==0.0.254
flake8-typing-imports==1.14.0;python_version>='3.8'
isort==5.12.0;python_version>='3.8'
mypy==1.0.1

0 comments on commit 5c51bc5

Please sign in to comment.