Skip to content

Commit d74f4cd

Browse files
committed
Use flake8+ruff for format
1 parent a766c33 commit d74f4cd

3 files changed

Lines changed: 52 additions & 2 deletions

File tree

ruff.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
line-length = 88
2+
target-version = "py310"
3+
4+
extend-exclude = [
5+
"doc",
6+
"tools",
7+
"*openstack/common*",
8+
"*lib/python*",
9+
"*egg",
10+
]
11+
12+
[lint]
13+
select = ["E", "W", "F"]
14+
15+
ignore = [
16+
"E251",
17+
"E305",
18+
"E731",
19+
"E117",
20+
"W605",
21+
"F632",
22+
"E501",
23+
]
24+
25+
[format]
26+
quote-style = "preserve"

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ oslotest>=3.8.0 # Apache-2.0
1010
stestr>=4.2.1 # Apache-2.0
1111
flake8>=7.0.0
1212
pyflakes>=3.2.0
13+
ruff>=0.5.0 # MIT

tox.ini

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ minversion = 4.0.2
33
envlist = py3,pep8,cover
44
skipsdist = True
55

6+
[vars]
7+
all_path = {toxinidir}
8+
69
[testenv]
710
usedevelop = True
811
setenv = VIRTUAL_ENV={envdir}
@@ -12,8 +15,25 @@ deps =
1215
git+https://github.com/cloudbase/python-coriolisclient.git
1316
commands = stestr run --slowest --exclude-regex coriolis.tests.integration {posargs}
1417

18+
[testenv:fmt]
19+
description = Format the code based on the coding style standards.
20+
deps =
21+
ruff
22+
commands =
23+
ruff check --select I --fix {[vars]all_path}
24+
ruff format {[vars]all_path}
25+
1526
[testenv:pep8]
16-
commands = flake8 {posargs}
27+
description = Verify the coding style (pep8).
28+
deps =
29+
ruff
30+
flake8>=7.0.0
31+
pyflakes>=3.2.0
32+
hacking>=7.0.0,<7.1.0
33+
commands =
34+
ruff format --diff {[vars]all_path}
35+
ruff check {[vars]all_path}
36+
flake8 {[vars]all_path}
1737

1838
[testenv:cover]
1939
setenv =
@@ -48,6 +68,9 @@ omit = coriolis/tests/*
4868
[flake8]
4969
# E125 is deliberately excluded. See https://github.com/jcrocholl/pep8/issues/126
5070
# E251 Skipped due to https://github.com/jcrocholl/pep8/issues/301
71+
#
72+
# E501 (line too long) is left to ruff
73+
# E203 (whitespace before ':') conflicts with how ruff formats slices.
5174

52-
ignore = E125,E251,W503,W504,E305,E731,E117,W605,F632,H401,H403,H404,H405,H202
75+
ignore = E125,E251,W503,W504,E305,E731,E117,W605,F632,H401,H403,H404,H405,H202,E501,E203,H301,H306
5376
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools

0 commit comments

Comments
 (0)