Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infra: update the pre-commit hook with linters #678

Merged
merged 18 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .git-template/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
if [ -f .pre-commit-config.yaml ]; then
echo 'pre-commit configuration detected, but `pre-commit install` was never run' 1>&2
exit 1
fi

speller26 marked this conversation as resolved.
Show resolved Hide resolved
24 changes: 7 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
repos:
- repo: local
hooks:
- id: tox
name: tox
stages: [push]
language: system
entry: tox
types: [python]
pass_filenames: false

- id: tox_integ_tests
name: tox integ tests
stages: [push]
language: system
entry: tox -e integ-tests
types: [python]
pass_filenames: false
Comment on lines -4 to -18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove these? We want the tests to pass before committing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I debated keeping the unit-tests run but I am hesitant around keeping the integ-tests. As these require an AWS account, I am not sure we should expect these to be ran by all contributors.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing integ tests makes sense, but I think unit tests are still good to have.

- repo: local
hooks:
- id: tox_linters
name: linters
entry: tox -e linters_check
language: system
types: [python]
19 changes: 19 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ commands =
{[testenv:black]commands}
{[testenv:flake8]commands}

# Read only linter env
[testenv:linters_check]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not also run isort -c?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! I missed this as an option. I am also planning on using this test env here in our workflows: https://github.com/aws/amazon-braket-sdk-python/blob/main/.github/workflows/check-format.yml#L29. I shall add this check in for both.
Although, I have been eyeing up ruff a bit more recently to take on some of this work... out of scope for the PR.

basepython = python3
skip_install = true
deps =
{[testenv:black_check]deps}
{[testenv:flake8]deps}
commands =
{[testenv:black_check]commands}
{[testenv:flake8]commands}

[testenv:flake8]
basepython = python3
skip_install = true
Expand Down Expand Up @@ -68,6 +79,14 @@ deps =
commands =
black ./ {posargs}

[testenv:black_check]
basepython = python3
skip_install = true
deps =
black
commands =
black --check . {posargs}

[testenv:docs]
basepython = python3
deps =
Expand Down