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

chore: Fix pre-commit config, fix linting #116

Merged
merged 5 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,3 @@ devenv.local.nix

# pre-commit
.pre-commit-config.yaml

76 changes: 39 additions & 37 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,63 +1,65 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 # Use the ref you want to point at
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 # Use the ref you want to point at
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
# - id: trailing-whitespace
# Python-specific
- id: check-ast
- id: check-docstring-first
- id: debug-statements
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: detect-private-key
# - id: end-of-file-fixer
aborgna-q marked this conversation as resolved.
Show resolved Hide resolved
# - id: trailing-whitespace
- id: fix-byte-order-marker
- id: mixed-line-ending
# Python-specific
- id: check-ast
- id: check-docstring-first
- id: debug-statements

- repo: https://github.com/crate-ci/typos
rev: v1.16.23
- repo: https://github.com/crate-ci/typos
rev: v1.17.1
hooks:
- id: typos
args: []
- id: typos

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.7
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.13
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.3.0'
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.8.0"
hooks:
- id: mypy
pass_filenames: false
args: [--package=guppy]
additional_dependencies: [
ormsgpack,
pydantic,
]
- id: mypy
pass_filenames: false
args: [--package=guppylang]
additional_dependencies: [
graphviz,
networkx,
ormsgpack,
pydantic,
pytket,
]

- repo: local
- repo: local
hooks:
- id: cargo-check
- id: cargo-check
name: Cargo check
entry: bash -c 'cd validator && exec cargo check'
pass_filenames: false
types: [file, rust]
language: system
- id: rust-linting
- id: rust-linting
name: Rust linting
entry: bash -c 'cd validator && exec cargo fmt --all --'
pass_filenames: true
types: [file, rust]
language: system
- id: rust-clippy
- id: rust-clippy
name: Rust clippy
entry: bash -c 'cd validator && exec cargo clippy --all-targets --all-features -- -Dclippy::all'
pass_filenames: false
Expand Down
2 changes: 1 addition & 1 deletion devenv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ inputs:
url: github:nix-community/fenix
inputs:
nixpkgs:
follows: nixpkgs
follows: nixpkgs
9 changes: 3 additions & 6 deletions tests/error/test_py_errors.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
from importlib.util import find_spec

import pathlib
import pytest

from tests.error.util import run_error_test


try:
import tket2

tket2_installed = True
except ImportError:
tket2_installed = False
tket2_installed = find_spec("tket2") is not None


path = pathlib.Path(__file__).parent.resolve() / "py_errors"
Expand Down
12 changes: 4 additions & 8 deletions tests/integration/test_py.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from importlib.util import find_spec

import pytest

from guppylang.decorator import guppy
Expand All @@ -6,13 +8,7 @@
from tests.integration.util import py
from tests.util import compile_guppy


try:
import tket2

tket2_installed = True
except ImportError:
tket2_installed = False
tket2_installed = find_spec("tket2") is not None


def test_basic(validate):
Expand Down Expand Up @@ -107,7 +103,7 @@ def test_pytket_multi_qubit(validate):
module.load(quantum)

@guppy(module)
def foo(q1: Qubit, q2:Qubit, q3:Qubit) -> tuple[Qubit, Qubit, Qubit]:
def foo(q1: Qubit, q2: Qubit, q3: Qubit) -> tuple[Qubit, Qubit, Qubit]:
return py(circ)(q1, q2, q3)

validate(module.compile())
Expand Down