diff --git a/.gitignore b/.gitignore index f2582958..1fe6322b 100644 --- a/.gitignore +++ b/.gitignore @@ -160,4 +160,3 @@ devenv.local.nix # pre-commit .pre-commit-config.yaml - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b40b54ec..62dd3eaa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 + # - 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 diff --git a/devenv.yaml b/devenv.yaml index 87a8faa4..62b57224 100644 --- a/devenv.yaml +++ b/devenv.yaml @@ -5,4 +5,4 @@ inputs: url: github:nix-community/fenix inputs: nixpkgs: - follows: nixpkgs \ No newline at end of file + follows: nixpkgs diff --git a/tests/error/test_py_errors.py b/tests/error/test_py_errors.py index 84b4cb60..6bcc57e4 100644 --- a/tests/error/test_py_errors.py +++ b/tests/error/test_py_errors.py @@ -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" diff --git a/tests/integration/test_py.py b/tests/integration/test_py.py index 93dbf299..1908d85e 100644 --- a/tests/integration/test_py.py +++ b/tests/integration/test_py.py @@ -1,3 +1,5 @@ +from importlib.util import find_spec + import pytest from guppylang.decorator import guppy @@ -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): @@ -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())