Skip to content

Commit

Permalink
Merge branch 'main' into feat/hugr-json
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q authored Jan 11, 2024
2 parents d848bc4 + e17ac31 commit 773e3bd
Show file tree
Hide file tree
Showing 11 changed files with 894 additions and 37 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Install poetry
run: pipx install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: pyproject.toml
cache: "poetry"

- name: Build Hugr validator
uses: PyO3/maturin-action@v1
Expand All @@ -29,14 +29,14 @@ jobs:
rust-toolchain: '1.75'
working-directory: validator

- name: Install Hugr validator
run: pip install validator/target/wheels/*

- name: Install Guppy
run: pip install -e '.[dev]'
run: poetry install

- name: Install Hugr validator
run: poetry add validator/target/wheels/*

- name: Type check with mypy
run: mypy guppy
run: poetry run mypy guppy

- name: Check formatting with ruff
uses: chartboost/ruff-action@v1
Expand All @@ -51,4 +51,4 @@ jobs:
args: check

- name: Run tests
run: pytest
run: poetry run pytest
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,14 @@ cython_debug/
.idea/

.DS_Store

# Devenv
.devenv*
devenv.local.nix

# direnv
.direnv

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

195 changes: 195 additions & 0 deletions devenv.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1704835383,
"narHash": "sha256-SoC0rYR9iHW0dVOEmxNEfa8vk9dTK86P5iXTgHafmwM=",
"owner": "cachix",
"repo": "devenv",
"rev": "18ef9849d1ecac7a9a7920eb4f2e4adcf67a8c3a",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1704867811,
"narHash": "sha256-pG4O1vPpNSMjz7p/5x+/OH4tXC0thzAPbJ55kI/W5dU=",
"owner": "nix-community",
"repo": "fenix",
"rev": "93e89638c15512db65e931f26ce36edf8cfbb4a5",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1704842529,
"narHash": "sha256-OTeQA+F8d/Evad33JMfuXC89VMetQbsU4qcaePchGr4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "eabe8d3eface69f5bb16c18f8662a702f50c20d5",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1704725188,
"narHash": "sha256-qq8NbkhRZF1vVYQFt1s8Mbgo8knj+83+QlL5LBnYGpI=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "ea96f0c05924341c551a797aaba8126334c505d2",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"fenix": "fenix",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1704833483,
"narHash": "sha256-Ox01mpYmjapNYaqOu4fMS/4Ma9NLd2rVNz6d4rJmcf4=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "ae6e73772432cfe35bb0ff6de6fdcfa908642b67",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
16 changes: 16 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{ ... }:

{
languages.python = {
enable = true;
poetry = {
enable = true;
activate.enable = true;
};
};

languages.rust = {
enable = true;
channel = "stable";
};
}
8 changes: 8 additions & 0 deletions devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
inputs:
nixpkgs:
url: github:NixOS/nixpkgs/nixpkgs-unstable
fenix:
url: github:nix-community/fenix
inputs:
nixpkgs:
follows: nixpkgs
4 changes: 2 additions & 2 deletions guppy/cfg/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def visit_FunctionDef(
bb.statements.append(new_node)
return bb

def generic_visit(self, node: ast.AST, bb: BB, jumps: Jumps) -> BB | None: # type: ignore[override]
def generic_visit(self, node: ast.AST, bb: BB, jumps: Jumps) -> BB | None:
# When adding support for new statements, we have to remember to use the
# ExprBuilder to transform all included expressions!
raise GuppyError("Statement is not supported", node)
Expand Down Expand Up @@ -365,7 +365,7 @@ def visit_IfExp(self, node: ast.IfExp, bb: BB, true_bb: BB, false_bb: BB) -> Non
self.visit(node.body, then_bb, true_bb, false_bb)
self.visit(node.orelse, else_bb, true_bb, false_bb)

def generic_visit(self, node: ast.expr, bb: BB, true_bb: BB, false_bb: BB) -> None: # type: ignore[override]
def generic_visit(self, node: ast.expr, bb: BB, true_bb: BB, false_bb: BB) -> None:
# We can always fall back to building the node as a regular expression and using
# the result as a branch predicate
pred, bb = ExprBuilder.build(node, self.cfg, bb)
Expand Down
4 changes: 1 addition & 3 deletions guppy/checker/expr_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ def visit_Call(self, node: ast.Call, ty: GuppyType) -> tuple[ast.expr, Subst]:
else:
raise GuppyTypeError(f"Expected function type, got `{func_ty}`", node.func)

def generic_visit( # type: ignore[override]
self, node: ast.expr, ty: GuppyType
) -> tuple[ast.expr, Subst]:
def generic_visit(self, node: ast.expr, ty: GuppyType) -> tuple[ast.expr, Subst]:
# Try to synthesize and then check if we can unify it with the given type
node, synth = self._synthesize(node, allow_free_vars=False)
subst, inst = check_type_against(synth, ty, node, self._kind)
Expand Down
2 changes: 1 addition & 1 deletion guppy/hugr/hugr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass, field
from typing import Any, Optional

import networkx as nx # type: ignore[import]
import networkx as nx # type: ignore[import-untyped]

import guppy.hugr.ops as ops
import guppy.hugr.raw as raw
Expand Down
2 changes: 1 addition & 1 deletion guppy/hugr/visualise.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections.abc import Iterable
from typing import TYPE_CHECKING

import graphviz as gv # type: ignore[import]
import graphviz as gv # type: ignore[import-untyped]

from guppy.cfg.analysis import (
DefAssignmentDomain,
Expand Down
Loading

0 comments on commit 773e3bd

Please sign in to comment.