Skip to content

Commit

Permalink
infra: onboard to use ruff (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbeCoull authored Oct 31, 2024
1 parent a2e7add commit 63d5cce
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 68 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/check-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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

27 changes: 0 additions & 27 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 8 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/braket/_schemas/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
47 changes: 19 additions & 28 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 63d5cce

Please sign in to comment.