From 4c2b5a90b5d48b001c7d5342a7d9d43d83c5b658 Mon Sep 17 00:00:00 2001 From: Kartik Singhal Date: Fri, 31 May 2024 09:21:39 -0500 Subject: [PATCH] chore: update pre-commit and apply suggestions (#233) can be automated using `pre-commit autoupdate` --- .pre-commit-config.yaml | 9 +++++---- .release-please-manifest.json | 2 +- .typos.toml | 3 ++- README.md | 2 +- docs/api-docs/.gitignore | 2 +- docs/build.sh | 2 ++ examples/1-Getting-Started.md | 1 - guppylang/definition/declaration.py | 2 +- guppylang/definition/struct.py | 4 ++-- guppylang/tys/var.py | 2 +- release-please-config.json | 2 +- tests/integration/test_basic.py | 3 ++- tests/integration/test_struct.py | 5 +++-- validator/src/lib.rs | 2 +- 14 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7fa21412..3422a4cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 # Use the ref you want to point at + rev: v4.6.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -20,24 +20,25 @@ repos: - id: debug-statements - repo: https://github.com/crate-ci/typos - rev: v1.19.0 + rev: v1.21.0 hooks: - id: typos - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.5 + rev: v0.4.6 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.8.0" + rev: "v1.10.0" hooks: - id: mypy pass_filenames: false args: [--package=guppylang] additional_dependencies: [ + hugr, graphviz, networkx, ormsgpack, diff --git a/.release-please-manifest.json b/.release-please-manifest.json index da59f99e..2537c1f1 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { ".": "0.4.0" -} \ No newline at end of file +} diff --git a/.typos.toml b/.typos.toml index 92413257..03e5011d 100644 --- a/.typos.toml +++ b/.typos.toml @@ -1,3 +1,4 @@ [default.extend-words] -inot = "inot" fle = "fle" +ine = "ine" +inot = "inot" diff --git a/README.md b/README.md index aea04f95..53e4d16f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [codecov]: https://img.shields.io/codecov/c/gh/CQCL/guppylang?logo=codecov [py-version]: https://img.shields.io/pypi/pyversions/guppylang - [pypi]: https://img.shields.io/pypi/v/guppylang + [pypi]: https://img.shields.io/pypi/v/guppylang Guppy is a quantum programming language that is fully embedded into Python. It allows you to write high-level hybrid quantum programs with classical control flow and mid-circuit measurements using Pythonic syntax: diff --git a/docs/api-docs/.gitignore b/docs/api-docs/.gitignore index df91f175..cd6936e2 100644 --- a/docs/api-docs/.gitignore +++ b/docs/api-docs/.gitignore @@ -1,3 +1,3 @@ _autosummary _build -generated \ No newline at end of file +generated diff --git a/docs/build.sh b/docs/build.sh index 66bde126..ff202cc9 100755 --- a/docs/build.sh +++ b/docs/build.sh @@ -1,3 +1,5 @@ +#!/bin/sh + mkdir build touch build/.nojekyll # Disable jekyll to keep files starting with underscores diff --git a/examples/1-Getting-Started.md b/examples/1-Getting-Started.md index 047f1a56..822fcd05 100644 --- a/examples/1-Getting-Started.md +++ b/examples/1-Getting-Started.md @@ -4,4 +4,3 @@ This file explains how you can get started using Guppy. TODO - diff --git a/guppylang/definition/declaration.py b/guppylang/definition/declaration.py index 13ccc06a..588599ef 100644 --- a/guppylang/definition/declaration.py +++ b/guppylang/definition/declaration.py @@ -66,7 +66,7 @@ def synthesize_call( return node, ty def compile_outer(self, graph: Hugr, parent: Node) -> "CompiledFunctionDecl": - """Adds a Hugr `FuncDecl` node for this funciton to the Hugr.""" + """Adds a Hugr `FuncDecl` node for this function to the Hugr.""" node = graph.add_declare(self.ty, parent, self.name) return CompiledFunctionDecl( self.id, self.name, self.defined_at, self.ty, self.python_func, node diff --git a/guppylang/definition/struct.py b/guppylang/definition/struct.py index 508bc212..0d5a722a 100644 --- a/guppylang/definition/struct.py +++ b/guppylang/definition/struct.py @@ -116,8 +116,8 @@ def parse(self, globals: Globals) -> "ParsedStructDef": raise GuppyError("Unexpected statement in struct", node) # Ensure that functions don't override struct fields - if overriden := used_field_names.intersection(used_func_names.keys()): - x = overriden.pop() + if overridden := used_field_names.intersection(used_func_names.keys()): + x = overridden.pop() raise GuppyError( f"Struct `{self.name}` already contains a field named `{x}`", used_func_names[x], diff --git a/guppylang/tys/var.py b/guppylang/tys/var.py index 43555d6f..fc332304 100644 --- a/guppylang/tys/var.py +++ b/guppylang/tys/var.py @@ -4,7 +4,7 @@ from dataclasses import dataclass from typing import ClassVar -# Type of de Bruijn indicies +# Type of de Bruijn indices DeBruijn = int # Type of unique variable identifiers diff --git a/release-please-config.json b/release-please-config.json index eb91fc5a..35868750 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -10,4 +10,4 @@ } }, "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json" -} \ No newline at end of file +} diff --git a/tests/integration/test_basic.py b/tests/integration/test_basic.py index d69f54e6..5dc48be7 100644 --- a/tests/integration/test_basic.py +++ b/tests/integration/test_basic.py @@ -81,7 +81,8 @@ def test_func_decl_name(): def func_name() -> None: ... [def_op] = [ - n.op.root for n in module.compile().nodes() + n.op.root + for n in module.compile().nodes() if isinstance(n.op.root, ops.FuncDecl) ] assert def_op.name == "func_name" diff --git a/tests/integration/test_struct.py b/tests/integration/test_struct.py index a37c12bc..a071ca6f 100644 --- a/tests/integration/test_struct.py +++ b/tests/integration/test_struct.py @@ -27,7 +27,9 @@ class DocstringStruct: x: int @guppy(module) - def main(a: EmptyStruct, b: OneMemberStruct, c: TwoMemberStruct, d: DocstringStruct) -> None: + def main( + a: EmptyStruct, b: OneMemberStruct, c: TwoMemberStruct, d: DocstringStruct + ) -> None: pass validate(module.compile()) @@ -94,4 +96,3 @@ def main(a: StructA[StructA[float]], b: StructB[int, bool], c: StructC) -> None: pass validate(module.compile()) - diff --git a/validator/src/lib.rs b/validator/src/lib.rs index a730c6a1..cfe30be8 100644 --- a/validator/src/lib.rs +++ b/validator/src/lib.rs @@ -2,9 +2,9 @@ use hugr::extension::{ExtensionRegistry, PRELUDE}; use hugr::std_extensions::arithmetic::{float_ops, float_types, int_ops, int_types}; use hugr::std_extensions::collections; use hugr::std_extensions::logic; -use tket2::extension::{TKET1_EXTENSION, TKET2_EXTENSION}; use lazy_static::lazy_static; use pyo3::prelude::*; +use tket2::extension::{TKET1_EXTENSION, TKET2_EXTENSION}; lazy_static! { pub static ref REGISTRY: ExtensionRegistry = ExtensionRegistry::try_new([