Skip to content

Commit 852997c

Browse files
authored
CI - add ruff check of the code (#7372)
- Add minimum ruff tool configuration to pyproject.toml - CI - add ruff to the "Lint check" CI job Partially implements #7371
1 parent e9f8691 commit 852997c

File tree

5 files changed

+32
-6
lines changed

5 files changed

+32
-6
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,15 @@ jobs:
113113
with:
114114
python-version: '3.11'
115115
architecture: 'x64'
116-
- name: Install pylint
117-
run: pip install -r dev_tools/requirements/pylint.env.txt
118-
- name: Display version
119-
run: check/pylint --version
120-
- name: Lint
116+
- name: Install lint tools
117+
run: pip install -r dev_tools/requirements/lint.env.txt
118+
- name: Display versions
119+
run: |
120+
ruff --version
121+
check/pylint --version
122+
- name: Lint with ruff
123+
run: FORCE_COLOR=1 ruff check
124+
- name: Lint with pylint
121125
run: check/pylint -v
122126
doc_test:
123127
if: github.repository_owner == 'quantumlib'

dev_tools/requirements/deps/dev-tools.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
-r notebook.txt
77
-r tensorflow-docs.txt
88
-r packaging.txt
9+
-r ruff.txt
910

1011
# For testing and analyzing code.
1112
asv
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ruff~=0.11.11

dev_tools/requirements/pylint.env.txt renamed to dev_tools/requirements/lint.env.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
-r deps/cirq-all.txt
33

44
-r deps/pylint.txt
5+
-r deps/ruff.txt

pyproject.toml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ include = [
1515
]
1616
omit = ["benchmarks/*"]
1717

18-
1918
[tool.coverage.report]
2019
exclude_also = [
2120
"^ *pass$",
@@ -48,3 +47,23 @@ markers = [
4847
]
4948
# Silence deprecation warnings about option "asyncio_default_fixture_loop_scope"
5049
asyncio_default_fixture_loop_scope = "function"
50+
51+
52+
[tool.ruff]
53+
line-length = 100
54+
target-version = "py311"
55+
extend-exclude = ["*_pb2.py*"]
56+
57+
[tool.ruff.lint]
58+
select = [
59+
# "ANN201", # missing-return-type-undocumented-public-function
60+
# "F401", # unused-import
61+
# "F601", # multi-value-repeated-key-literal
62+
"F821", # undefined-name
63+
"TC001", # typing-only-first-party-import
64+
"TC002", # typing-only-third-party-import
65+
# "TC003", # typing-only-standard-library-import
66+
"UP006", # non-pep585-annotation
67+
"UP007", # non-pep604-annotation-union
68+
"UP037", # quoted-annotation
69+
]

0 commit comments

Comments
 (0)