Skip to content

Commit

Permalink
feat: Support constructing ControlFlowGraph and BasicBlocks. (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarquessV authored Apr 17, 2024
1 parent a787618 commit 7839294
Show file tree
Hide file tree
Showing 19 changed files with 968 additions and 852 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/msrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:
command: test
args: --all-features

test-py:
name: Test quil-py
check-py:
name: Check quil-py
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -67,7 +67,7 @@ jobs:
- uses: davidB/rust-cargo-make@v1
- uses: actions/checkout@v1
- uses: snok/install-poetry@v1
- name: Run quil-py tests
- name: Run quil-py tests, lints, and formatting checks.
run: cargo make --cwd quil-py

fmt:
Expand Down
24 changes: 23 additions & 1 deletion quil-py/Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ command = "poetry"
args = ["run", "maturin", "develop"]

[tasks.stubtest]
dependencies = ["poetry-install"]
command = "poetry"
args = ["run", "stubtest", "--allowlist", ".stubtest-allowlist", "quil"]

Expand All @@ -20,6 +21,21 @@ dependencies = [
"stubtest",
]

[tasks.format]
dependencies = ["poetry-install"]
command = "poetry"
args = ["run", "ruff", "format"]

[tasks.check-format]
dependencies = ["poetry-install"]
command = "poetry"
args = ["run", "ruff", "format", "--check"]

[tasks.lint]
dependencies = ["poetry-install"]
command = "poetry"
args = ["run", "ruff", "check"]

[tasks.pytest]
command = "poetry"
args = ["run", "pytest"]
Expand All @@ -37,7 +53,13 @@ command = "poetry"
args = ["run", "pdoc", "-o", "build/docs", "quil", "!quil.quil", "--logo", "https://qcs.rigetti.com/static/img/rigetti-logo.svg"]

[tasks.dev-flow]
dependencies = ["dev-test-flow", "pytest-flow", "stubtest"]
dependencies = [
"dev-test-flow",
"pytest-flow",
"stubtest",
"lint",
"check-format"
]

[tasks.default]
alias = "dev-flow"
3 changes: 1 addition & 2 deletions quil-py/make_docs.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from pathlib import Path
import sys
from pathlib import Path

import pdoc

import quil # noqa - we need to import quil for it to appear in sys.modules


if __name__ == "__main__":
print(dir(sys.modules["quil"]))
print(dir(sys.modules["quil.validation"]))
Expand Down
117 changes: 27 additions & 90 deletions quil-py/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 75 additions & 4 deletions quil-py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ python = "^3.8"
numpy = "^1.21"

[tool.poetry.group.dev.dependencies]
black = "^23.1.0"
ruff = "^0.3.7"
maturin = "^1.2.3"
mypy = "^1.1.1"
pytest = "^7.2.2"
Expand All @@ -46,7 +46,78 @@ sdist-include = ["README.md"]
requires = ["maturin>=1.0.0,<2.0.0"]
build-backend = "maturin"

[tool.black]
[tool.ruff]
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]
line-length = 120
target-version = ['py38', 'py39', 'py310', 'py311']
include = '\.pyi?$'
indent-width = 4
target-version = "py38"

[tool.ruff.lint]
select = ["D", "E4", "E7", "E9", "F", "I", "B", "S", "W"]
ignore = [
"E741" # "Ambiguous" variable names like "I" aren't ambiguous in this contex.
]
fixable = ["ALL"]
unfixable = []
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.lint.per-file-ignores]
"quil/**/*.py" = [
"F403", # * imports allowed in extension module glue.
"D100", # docstrings belong in type stubs
"D104",
]
"test/**/*.py" = [
"D", # docstrings are not enforced in tests
"S101", # asserts are allowed in tests
"S301", # we need to test pickling
]
"make_docs.py" = [ "D" ]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.pyright]
# This diagnostic is raised when a type stub is found without a corresponding source file. This is
# necessarily the case for a pure Rust pyo3 module, so disabling it.
reportMissingModuleSource = false

[[tool.mypy.overrides]]
module = [
"quil.quil",
]
ignore_missing_imports = true
4 changes: 2 additions & 2 deletions quil-py/quil/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
The `quil` package provides tools for constructing, manipulating, parsing, and printing [Quil](https://github.com/quil-lang/quil) programs.
"""The `quil` package provides tools for constructing, manipulating, parsing, and printing [Quil](https://github.com/quil-lang/quil) programs.
⚠️ This package is still in early development and breaking changes should be expected between minor versions.
"""

from .quil import *
Loading

0 comments on commit 7839294

Please sign in to comment.