Skip to content

Commit 63d5cce

Browse files
authored
infra: onboard to use ruff (#184)
1 parent a2e7add commit 63d5cce

File tree

6 files changed

+38
-68
lines changed

6 files changed

+38
-68
lines changed

.github/workflows/check-format.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ jobs:
2020
python-version: '3.x'
2121
- name: Install dependencies
2222
run: |
23-
pip install --upgrade pip
24-
pip install -e .[test]
23+
pip install tox
2524
- name: Run code format checks
2625
run: |
27-
black --check .
28-
flake8
26+
tox -e linters_check

pyproject.toml

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1-
[tool.black]
1+
[tool.ruff]
2+
target-version = "py39"
23
line-length = 100
4+
lint.isort = { known-first-party = [
5+
"braket",
6+
] }
7+
lint.extend-select = ["I"]
8+
lint.preview = true
9+

setup.cfg

-27
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,3 @@ addopts =
77
--verbose -n auto
88
testpaths = test/unit_tests
99

10-
[isort]
11-
line_length = 100
12-
multi_line_output = 3
13-
include_trailing_comma = true
14-
15-
[flake8]
16-
ignore =
17-
# not pep8, black adds whitespace before ':'
18-
E203,
19-
# not pep8, black adds line break before binary operator
20-
W503,
21-
# needed for model regexes
22-
F722,
23-
# needed for model regexes
24-
F821,
25-
# Google Python style is not RST until after processed by Napoleon
26-
# See https://github.com/peterjc/flake8-rst-docstrings/issues/17
27-
RST201,RST203,RST301,
28-
max_line_length = 100
29-
max-complexity = 10
30-
exclude =
31-
__pycache__
32-
.tox
33-
.git
34-
bin
35-
build
36-
venv

setup.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,24 @@
2929
install_requires=["pydantic>2"],
3030
extras_require={
3131
"test": [
32-
"black",
33-
"flake8",
34-
"flake8-rst-docstrings",
35-
"isort",
3632
"jsonschema",
3733
"numpy",
3834
"pre-commit",
39-
"pylint",
4035
"pytest",
4136
"pytest-cov",
4237
"pytest-rerunfailures",
4338
"pytest-xdist",
39+
"tox",
40+
],
41+
"linters": [
42+
"ruff",
43+
"tox",
44+
],
45+
"docs": [
4446
"sphinx",
4547
"sphinx-rtd-theme",
4648
"sphinxcontrib-apidoc",
47-
"tox",
48-
]
49+
],
4950
},
5051
url="https://github.com/amazon-braket/amazon-braket-schemas-python",
5152
author="Amazon Web Services",

src/braket/_schemas/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# language governing permissions and limitations under the License.
1313

1414
"""Version information.
15-
Version number (major.minor.patch[-label])
15+
Version number (major.minor.patch[-label])
1616
"""
1717

1818
__version__ = "1.22.2.dev0"

tox.ini

+19-28
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,41 @@ extras = test
1010

1111
[testenv:linters]
1212
basepython = python3
13-
skip_install = true
13+
# Remove this to check what versions are installed for the env. This stops running pip freeze.
14+
list_dependencies_command = echo
1415
deps =
15-
{[testenv:isort]deps}
16-
{[testenv:black]deps}
17-
{[testenv:flake8]deps}
16+
{[testenv:ruff-format]deps}
17+
{[testenv:ruff-check]deps}
1818
commands =
19-
# isort MUST come before black as it will revert any changes made by black
20-
{[testenv:isort]commands}
21-
{[testenv:black]commands}
22-
{[testenv:flake8]commands}
19+
{[testenv:ruff-format]commands}
20+
{[testenv:ruff-check]commands}
2321

24-
[testenv:flake8]
22+
# Read only linter env
23+
[testenv:linters_check]
2524
basepython = python3
26-
skip_install = true
27-
deps =
28-
flake8
29-
flake8-rst-docstrings
25+
extras = linters
3026
commands =
31-
flake8 {posargs}
27+
{[testenv:ruff-check]commands}
3228

33-
[testenv:isort]
29+
[testenv:ruff-check]
3430
basepython = python3
35-
skip_install = true
36-
deps =
37-
isort
31+
extras = linters
32+
deps = ruff
3833
commands =
39-
isort -rc . {posargs}
34+
ruff check src {posargs}
4035

41-
[testenv:black]
36+
[testenv:ruff-format]
4237
basepython = python3
43-
skip_install = true
44-
deps =
45-
black
38+
extras = linters
39+
deps = ruff
4640
commands =
47-
black ./ {posargs}
41+
ruff format . {posargs}
4842

4943
[testenv:docs]
5044
basepython = python3
51-
deps =
52-
sphinx
53-
sphinx-rtd-theme
54-
sphinxcontrib-apidoc
5545
commands =
5646
sphinx-build -E -T -b html doc build/documentation/html
47+
extras = docs
5748

5849
[testenv:serve-docs]
5950
basepython = python3

0 commit comments

Comments
 (0)