Skip to content
Closed
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
41 changes: 41 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Static analysis

on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- main
workflow_dispatch: {}

concurrency:
group: fast-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
static_analysis:
name: Run static analysis tools (Ubuntu)
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.10"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout deltakit
uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install Hatch
run: |
pip install hatch
- name: Run linter (ruff)
run: |
hatch -v run static:lint
- name: Run type checker (mypy)
run: |
hatch -v run static:type
Comment on lines +20 to +41

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 8 months ago

To fix the problem, add a permissions block at the job or workflow level to limit the GITHUB_TOKEN to the least privileges required. Here, the static_analysis job only needs to check out the code and perform analysis, so it only requires read access to contents. The best fix is to add permissions: contents: read at the root level of the workflow (after the name: and before on:) to apply least privilege to all jobs unless overridden. Alternatively, the key can be placed on the static_analysis job alone. Generally, root-level is best unless certain jobs need differing scopes.

Specifically, insert:

permissions:
  contents: read

After the name: line in .github/workflows/static.yml.
No extra imports or dependencies are needed.

Suggested changeset 1
.github/workflows/static.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml
--- a/.github/workflows/static.yml
+++ b/.github/workflows/static.yml
@@ -1,4 +1,6 @@
 name: Static analysis
+permissions:
+  contents: read
 
 on:
   push:
EOF
@@ -1,4 +1,6 @@
name: Static analysis
permissions:
contents: read

on:
push:
Copilot is powered by AI and may make mistakes. Always verify output.
256 changes: 154 additions & 102 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
[build-system]
requires = ["setuptools>=80"]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "deltakit"
version = "0.5.1"
description = "Deltakit SDK"
description = "A Python toolkit to help users design and execute quantum error correction (QEC) experiments."
readme = "README.md"
requires-python = ">=3.10"
license = "Apache-2.0"
license-files = ["LICENSE"]
# keywords = {"quantum"}

authors = [{ name = "Deltakit Team", email = "deltakit@riverlane.com" }]

classifiers = [
"Development Status :: 1 - Planning",
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
Expand All @@ -25,9 +26,12 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Scientific/Engineering",
"Typing :: Typed",
]

dependencies = [
"deltakit_circuit",
"deltakit_core",
Expand All @@ -37,102 +41,113 @@ dependencies = [

[project.urls]
Homepage = "https://github.com/Deltakit/deltakit"
"Bug Tracker" = "https://github.com/Deltakit/deltakit/issues"
Source = "https://github.com/Deltakit/deltakit"
Documentation = "https://deltakit.riverlane.com/"
Issues = "https://github.com/Deltakit/deltakit/issues"
Changelog = "https://github.com/Deltakit/deltakit/releases"

[project.optional-dependencies]
# any changes here should be duplicated to dev dependency list
# AND feature.pytest.dependencies in pixi.toml
tests = [
"pytest>=8.4.1,<9",
"pytest-cov>=6.2.1,<7",
"pytest-mock>=3.14.1,<4",
"pytest-asyncio>=1.0.0,<2",
"pytest-skip-slow>=0.0.5",
"pytest-testmon>=2.0, <3",
"pytest-lazy-fixtures>=1.0, <2",
]
# any changes here should be duplicated to dev dependency list
lint = [
"mypy>=1.17,<2",
"ruff>=0.12.2,<0.13",
"typos>=1.34.0,<2",
"isort>=6.0",
]
# any changes here should be duplicated to dev dependency list
docs = [
"myst_nb>=1.0,<2.0",
"sphinxawesome-theme>=5.3.2,<6",
"sphinx-autodoc-typehints>=3.0.0,<4",
"sphinx-copybutton>=0.5.2,<0.6",
"pip-licenses>=5.0",
"sphinx-design>0.6, <1.0",
"sphinx-autobuild>=2024.10.3",
"myst-parser>=4.0, <5",
"vale>=3.12.0.0",
"jupytext>=1.17.0,<2",
"jupyter>=1.1.1,<2",
"ipykernel >=6.29.5,<7"
]
# any changes here should be duplicated to dev dependency list
build = [
"build>=1.2.0",
]
# any changes here should be duplicated to dev dependency list
security = [
"bandit>=1.8.6,<2",
"ochrona>=2.0.2,<3.0",
"pip-audit >=2.7.3",
]
dev = [
# poetry seems to be having trouble with elements of
# deltakit being "listed as a dependency of itself".
# this list needs to contain all dependencies in other groups
# (tests, lint, docs, build, security) + dev
# "deltakit[tests]",
"pytest>=8.4.1,<9",
"pytest-cov>=6.2.1,<7",
"pytest-mock>=3.14.1,<4",
"pytest-asyncio>=1.0.0,<2",
"pytest-skip-slow>=0.0.5",
"pytest-testmon>=2.0, <3",
"pytest-lazy-fixtures>=1.0, <2",
# "deltakit[lint]",
"mypy>=1.17,<2",
"ruff>=0.12.2,<0.13",
"typos>=1.34.0,<2",
"isort>=6.0",
# "deltakit[docs]",
"myst_nb>=1.0,<2.0",
"sphinxawesome-theme>=5.3.2,<6",
"sphinx-autodoc-typehints>=3.0.0,<4",
"sphinx-copybutton>=0.5.2,<0.6",
"pip-licenses>=5.0",
"sphinx-design>0.6, <1.0",
"sphinx-autobuild>=2024.10.3",
"myst-parser>=4.0, <5",
"vale>=3.12.0.0",
"jupytext>=1.17.0,<2",
"jupyter>=1.1.1,<2",
# "deltakit[build]",
"build>=1.2.0",
# "deltakit[security]",
"bandit>=1.8.6,<2",
"ochrona>=2.0.2,<3.0",
"pip-audit >=2.7.3",
# other
"pre-commit>=4.2.0,<5",
"ipykernel>=6.29.5,<7",
"validate-pyproject>=0.24.1",
"python-semantic-release>=10.2.0",
"tomlkit>=0.13,<1",
"deptry>=0.23, <1",
"ipykernel >=6.29.5,<7",
]
# [project.optional-dependencies]
# # any changes here should be duplicated to dev dependency list
# # AND feature.pytest.dependencies in pixi.toml
# tests = [
# "pytest>=8.4.1,<9",
# "pytest-cov>=6.2.1,<7",
# "pytest-mock>=3.14.1,<4",
# "pytest-asyncio>=1.0.0,<2",
# "pytest-skip-slow>=0.0.5",
# "pytest-testmon>=2.0, <3",
# "pytest-lazy-fixtures>=1.0, <2",
# ]
# # any changes here should be duplicated to dev dependency list
# lint = [
# "mypy>=1.17,<2",
# "ruff>=0.12.2,<0.13",
# "typos>=1.34.0,<2",
# "isort>=6.0",
# ]
# # any changes here should be duplicated to dev dependency list
# docs = [
# "myst_nb>=1.0,<2.0",
# "sphinxawesome-theme>=5.3.2,<6",
# "sphinx-autodoc-typehints>=3.0.0,<4",
# "sphinx-copybutton>=0.5.2,<0.6",
# "pip-licenses>=5.0",
# "sphinx-design>0.6, <1.0",
# "sphinx-autobuild>=2024.10.3",
# "myst-parser>=4.0, <5",
# "vale>=3.12.0.0",
# "jupytext>=1.17.0,<2",
# "jupyter>=1.1.1,<2",
# "ipykernel >=6.29.5,<7"
# ]
# # any changes here should be duplicated to dev dependency list
# build = [
# "build>=1.2.0",
# ]
# # any changes here should be duplicated to dev dependency list
# security = [
# "bandit>=1.8.6,<2",
# "ochrona>=2.0.2,<3.0",
# "pip-audit >=2.7.3",
# ]
# dev = [
# # poetry seems to be having trouble with elements of
# # deltakit being "listed as a dependency of itself".
# # this list needs to contain all dependencies in other groups
# # (tests, lint, docs, build, security) + dev
# # "deltakit[tests]",
# "sphinxawesome-theme>=5.3.2,<6",
# "sphinx-autodoc-typehints>=3.0.0,<4",
# "sphinx-copybutton>=0.5.2,<0.6",
# "pip-licenses>=5.0",
# "sphinx-design>0.6, <1.0",
# "sphinx-autobuild>=2024.10.3",
# "myst-parser>=4.0, <5",
# "vale>=3.12.0.0",
# "jupytext>=1.17.0,<2",
# "jupyter>=1.1.1,<2",
# # "deltakit[build]",
# "build>=1.2.0",
# # "deltakit[security]",
# "bandit>=1.8.6,<2",
# "ochrona>=2.0.2,<3.0",
# "pip-audit >=2.7.3",
# # other
# "pre-commit>=4.2.0,<5",
# "ipykernel>=6.29.5,<7",
# "validate-pyproject>=0.24.1",
# "python-semantic-release>=10.2.0",
# "tomlkit>=0.13,<1",
# "deptry>=0.23, <1",
# "ipykernel >=6.29.5,<7",
# ]

# for mypy configuration, see `mypy.ini`.
# for ruff configuration, see `ruff.toml`

[tool.hatch.envs.default]
installer = "uv"
dependencies = [
"pytest>=8.4.1,<9",
"pytest-cov>=6.2.1,<7",
"pytest-mock>=3.14.1,<4",
"pytest-xdist",
"pytest-markdown-docs",
"pytest-asyncio>=1.0.0,<2",
"pytest-skip-slow>=0.0.5",
"pytest-testmon>=2.0, <3",
"pytest-lazy-fixtures>=1.0, <2",
# "deltakit[lint]",
# "mypy>=1.17,<2",
# "ruff>=0.12.2,<0.13",
# "typos>=1.34.0,<2",
# "isort>=6.0",
]

[tool.hatch.envs.default.scripts]
test = "pytest -n auto --cov-report=xml --cov-config=pyproject.toml --cov=mis --cov=tests --markdown-docs {args}"
test_readme = "pytest --markdown-docs README.md"

[tool.pytest.ini_options]
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
Expand All @@ -144,6 +159,43 @@ filterwarnings = [
"ignore:This process .* is multi-threaded, use of fork\\(\\) may lead to deadlocks in the child.:DeprecationWarning"
]

[tool.hatch.envs.static]
description = "Static analysis for the monorepo."
installer = "uv"
dependencies = [
"mypy>=1.17,<2",
"ruff>=0.12.2,<0.13",
"typos>=1.34.0,<2",
"isort>=6.0",
]

[tool.hatch.envs.static.scripts]
lint = "ruff check ."
type = "mypy ."

[tool.hatch.envs.docs]
description = "Build and serve docs using Sphinx."
installer = "uv"
dependencies = [
"myst_nb>=1.0,<2.0",
"sphinxawesome-theme>=5.3.2,<6",
"sphinx-autodoc-typehints>=3.0.0,<4",
"sphinx-copybutton>=0.5.2,<0.6",
"pip-licenses>=5.0",
"sphinx-design>0.6, <1.0",
"sphinx-autobuild>=2024.10.3",
"myst-parser>=4.0, <5",
"vale>=3.12.0.0",
"jupytext>=1.17.0,<2",
"jupyter>=1.1.1,<2",
"ipykernel >=6.29.5,<7"
]

[tool.hatch.envs.docs.scripts]
build = "sphinx-build -v -W -b html docs docs/_build/html"
serve = "python -m http.server --directory docs/_build/html"


[tool.isort]
skip = [".pixi", ".tox", ".venv"]

Expand Down Expand Up @@ -238,14 +290,14 @@ deltakit-circuit = { path = "./deltakit-circuit/", develop = true }
deltakit-decode = { path = "./deltakit-decode/", develop = true }
deltakit-explorer = { path = "./deltakit-explorer/", develop = true }

[tool.hatch.envs.default]
pre-install-commands = [
"pip install -e ./deltakit-core",
"pip install -e ./deltakit-circuit",
"pip install -e ./deltakit-decode",
"pip install -e ./deltakit-explorer",
]
features = ["dev"]
# [tool.hatch.envs.default]
# pre-install-commands = [
# "pip install -e ./deltakit-core",
# "pip install -e ./deltakit-circuit",
# "pip install -e ./deltakit-decode",
# "pip install -e ./deltakit-explorer",
# ]
# features = ["dev"]

[tool.uv.workspace]
members = [
Expand Down
Loading