diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1286e023642..ee8296d8660 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -113,11 +113,15 @@ jobs: with: python-version: '3.11' architecture: 'x64' - - name: Install pylint - run: pip install -r dev_tools/requirements/pylint.env.txt - - name: Display version - run: check/pylint --version - - name: Lint + - name: Install lint tools + run: pip install -r dev_tools/requirements/lint.env.txt + - name: Display versions + run: | + ruff --version + check/pylint --version + - name: Lint with ruff + run: FORCE_COLOR=1 ruff check + - name: Lint with pylint run: check/pylint -v doc_test: if: github.repository_owner == 'quantumlib' diff --git a/dev_tools/requirements/deps/dev-tools.txt b/dev_tools/requirements/deps/dev-tools.txt index 837edd375d3..507b4c76c71 100644 --- a/dev_tools/requirements/deps/dev-tools.txt +++ b/dev_tools/requirements/deps/dev-tools.txt @@ -6,6 +6,7 @@ -r notebook.txt -r tensorflow-docs.txt -r packaging.txt +-r ruff.txt # For testing and analyzing code. asv diff --git a/dev_tools/requirements/deps/ruff.txt b/dev_tools/requirements/deps/ruff.txt new file mode 100644 index 00000000000..66ae386e831 --- /dev/null +++ b/dev_tools/requirements/deps/ruff.txt @@ -0,0 +1 @@ +ruff~=0.11.11 diff --git a/dev_tools/requirements/pylint.env.txt b/dev_tools/requirements/lint.env.txt similarity index 85% rename from dev_tools/requirements/pylint.env.txt rename to dev_tools/requirements/lint.env.txt index 2bc8c490773..2b6c8b7c70a 100644 --- a/dev_tools/requirements/pylint.env.txt +++ b/dev_tools/requirements/lint.env.txt @@ -2,3 +2,4 @@ -r deps/cirq-all.txt -r deps/pylint.txt +-r deps/ruff.txt diff --git a/pyproject.toml b/pyproject.toml index 9a395d5f583..b4726ceffa4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,6 @@ include = [ ] omit = ["benchmarks/*"] - [tool.coverage.report] exclude_also = [ "^ *pass$", @@ -48,3 +47,23 @@ markers = [ ] # Silence deprecation warnings about option "asyncio_default_fixture_loop_scope" asyncio_default_fixture_loop_scope = "function" + + +[tool.ruff] +line-length = 100 +target-version = "py311" +extend-exclude = ["*_pb2.py*"] + +[tool.ruff.lint] +select = [ + # "ANN201", # missing-return-type-undocumented-public-function + # "F401", # unused-import + # "F601", # multi-value-repeated-key-literal + "F821", # undefined-name + "TC001", # typing-only-first-party-import + "TC002", # typing-only-third-party-import + # "TC003", # typing-only-standard-library-import + "UP006", # non-pep585-annotation + "UP007", # non-pep604-annotation-union + "UP037", # quoted-annotation +]