From 7a07e13e35efb87c3d04390f45bd5d6382a973dd Mon Sep 17 00:00:00 2001 From: Coull Date: Fri, 4 Oct 2024 10:18:22 -0700 Subject: [PATCH 1/2] infra: onboard to use ruff --- pyproject.toml | 9 ++++++- setup.cfg | 27 ------------------- setup.py | 15 ++++++----- src/braket/_schemas/_version.py | 2 +- tox.ini | 47 +++++++++++++-------------------- 5 files changed, 36 insertions(+), 64 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index aa4949aa..d74c909c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,9 @@ -[tool.black] +[tool.ruff] +target-version = "py39" line-length = 100 +lint.isort = { known-first-party = [ + "braket", +] } +lint.extend-select = ["I"] +lint.preview = true + diff --git a/setup.cfg b/setup.cfg index f63b67f7..74974596 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,30 +7,3 @@ addopts = --verbose -n auto testpaths = test/unit_tests -[isort] -line_length = 100 -multi_line_output = 3 -include_trailing_comma = true - -[flake8] -ignore = - # not pep8, black adds whitespace before ':' - E203, - # not pep8, black adds line break before binary operator - W503, - # needed for model regexes - F722, - # needed for model regexes - F821, - # Google Python style is not RST until after processed by Napoleon - # See https://github.com/peterjc/flake8-rst-docstrings/issues/17 - RST201,RST203,RST301, -max_line_length = 100 -max-complexity = 10 -exclude = - __pycache__ - .tox - .git - bin - build - venv diff --git a/setup.py b/setup.py index da01e75e..57bf5fc6 100644 --- a/setup.py +++ b/setup.py @@ -29,23 +29,24 @@ install_requires=["pydantic>2"], extras_require={ "test": [ - "black", - "flake8", - "flake8-rst-docstrings", - "isort", "jsonschema", "numpy", "pre-commit", - "pylint", "pytest", "pytest-cov", "pytest-rerunfailures", "pytest-xdist", + "tox", + ], + "linters": [ + "ruff", + "tox", + ], + "docs": [ "sphinx", "sphinx-rtd-theme", "sphinxcontrib-apidoc", - "tox", - ] + ], }, url="https://github.com/amazon-braket/amazon-braket-schemas-python", author="Amazon Web Services", diff --git a/src/braket/_schemas/_version.py b/src/braket/_schemas/_version.py index a4193c6a..2385f4dc 100644 --- a/src/braket/_schemas/_version.py +++ b/src/braket/_schemas/_version.py @@ -12,7 +12,7 @@ # language governing permissions and limitations under the License. """Version information. - Version number (major.minor.patch[-label]) +Version number (major.minor.patch[-label]) """ __version__ = "1.22.2.dev0" diff --git a/tox.ini b/tox.ini index a763b1f7..38b19d15 100644 --- a/tox.ini +++ b/tox.ini @@ -10,50 +10,41 @@ extras = test [testenv:linters] basepython = python3 -skip_install = true +# Remove this to check what versions are installed for the env. This stops running pip freeze. +list_dependencies_command = echo deps = - {[testenv:isort]deps} - {[testenv:black]deps} - {[testenv:flake8]deps} + {[testenv:ruff-format]deps} + {[testenv:ruff-check]deps} commands = - # isort MUST come before black as it will revert any changes made by black - {[testenv:isort]commands} - {[testenv:black]commands} - {[testenv:flake8]commands} + {[testenv:ruff-format]commands} + {[testenv:ruff-check]commands} -[testenv:flake8] +# Read only linter env +[testenv:linters_check] basepython = python3 -skip_install = true -deps = - flake8 - flake8-rst-docstrings +extras = linters commands = - flake8 {posargs} + {[testenv:ruff-check]commands} -[testenv:isort] +[testenv:ruff-check] basepython = python3 -skip_install = true -deps = - isort +extras = linters +deps = ruff commands = - isort -rc . {posargs} + ruff check src {posargs} -[testenv:black] +[testenv:ruff-format] basepython = python3 -skip_install = true -deps = - black +extras = linters +deps = ruff commands = - black ./ {posargs} + ruff format . {posargs} [testenv:docs] basepython = python3 -deps = - sphinx - sphinx-rtd-theme - sphinxcontrib-apidoc commands = sphinx-build -E -T -b html doc build/documentation/html +extras = docs [testenv:serve-docs] basepython = python3 From c35f74846fbfa2b1bceaf493420fd89d545e2136 Mon Sep 17 00:00:00 2001 From: Coull Date: Fri, 4 Oct 2024 10:30:38 -0700 Subject: [PATCH 2/2] fix workflow --- .github/workflows/check-format.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml index cbd77d24..87bcb050 100644 --- a/.github/workflows/check-format.yml +++ b/.github/workflows/check-format.yml @@ -20,9 +20,7 @@ jobs: python-version: '3.x' - name: Install dependencies run: | - pip install --upgrade pip - pip install -e .[test] + pip install tox - name: Run code format checks run: | - black --check . - flake8 + tox -e linters_check