[project]
name = "erado"
description = "Simulation suite for erasure noise and postselection as quantum error mitigation."
authors = [
    { name = "Sam Griffiths", email = "sgriffiths@oqc.tech" },
]
readme = "docs/README.md"
license = "BSD-3-Clause"
license-files = ["LICENSE"]
dynamic = ["version"]
requires-python = ">=3.13"
dependencies = [
    "numpy>=2.3.3",
    "scipy>=1.16.2",
    "matplotlib>=3.10.6",
    "qiskit>=2.2.1",
    "qiskit-aer-gpu-cu11>=0.17.2; sys_platform == 'linux'",
    "qiskit-aer>=0.17.2; sys_platform != 'linux'",
    "pydantic>=2.12.0",
]

[dependency-groups]
dev = [
    "poethepoet>=0.37.0",
    "pyright[nodejs]>=1.1.406",
    "pre-commit>=4.3.0",
    "pytest>=8.4.2",
    "ruff>=0.14.0",
]
docs = [
    "furo>=2025.12.19",
    "gitpython>=3.1.46",
    "myst-parser>=5.0.0",
    "sphinx<9.0.0",  # sphinx-multiversion is currently broken for Sphinx 9
    "sphinx-autoapi>=3.7.0",
    "sphinx-multiversion>=0.2.4",
]

[project.urls]
homepage = "https://oqc.tech"
repository = "https://github.com/oqc-community/erado"
documentation = "https://oqc-community.github.io/erado"


[build-system]
requires = ["hatchling", "uv-dynamic-versioning"]
build-backend = "hatchling.build"

[tool.hatch.version]
source = "uv-dynamic-versioning"

[tool.uv-dynamic-versioning]
enable = true
style = "pep440"


[tool.poe.tasks]
lint = { cmd = "ruff check .", help = "Run linter (Ruff)" }
types = { cmd = "pyright .", help = "Run type checker (Pyright)" }
unit-tests = { cmd = "pytest tests/", help = "Run unit tests (pytest)" }

pre-commit = { cmd = "pre-commit run --all-files", help = "Run pre-commit hook rules on all files" }

stubs = { cmd = "python src/make_stubs.py qiskit._accelerate.circuit ./typings", help = "Generate type stubs for Qiskit circuit extension module" }

[tool.poe.tasks.checks]
sequence = [
    "lint",
    "types",
    "unit-tests",
]
ignore_fail = true
help = "Run all status checks (lint, types, unit-tests)"

[tool.poe.tasks.docs-build]
sequence = [
    { cmd = "rm -rf ${build_dir}" },
    { script = "docs.util.version:main" },
    { cmd = "sphinx-multiversion docs ${build_dir}", envfile = "version.env" },
    { script = "docs.util.redirect:main(environ['build_dir'])" },
]
args = [
    { name = "build_dir", default = "docs/_build", help = "Output build directory", positional = true },
]
help = "Clean-build docs site with all eligible versions (requires 'docs' group)"

[tool.poe.tasks.docs-preview]
sequence = [
    { cmd = "rm -rf ${build_dir}" },
    { cmd = "sphinx-build docs ${build_dir}/preview" },
    { script = "docs.util.redirect:main(environ['build_dir'])" },
]
args = [
    { name = "build_dir", default = "docs/_build", help = "Output build directory", positional = true },
]
help = "Clean-build docs site from just local working copy (requires 'docs' group)"


[tool.pyright]
typeCheckingMode = "standard"
reportImplicitOverride = "error"
exclude = [
    "typings",

    # Default pyright exclude entries:
    "**/node_modules",
    "**/__pycache__",
    "**/.*",
    ".venv",
]


[tool.ruff]
line-length = 120
extend-exclude = [
    "typings",
    "examples",
    "src/make_stubs.py",
    "docs",
]

[tool.ruff.lint]
ignore = [
    "ALL",     # Strictly opt-in to ruff functionality below
    "ANN204",  # Don't require return types on 'special' methods
]
select = [
    "E",       # Enable pycodestyle rules (line length etc.)
    "D",       # Enable pydocstyle rules
    "D401",    # Docstrings must have imperative mood
    "ANN",     # Type annotations are mandatory
    "F",       # Enable Pyflakes rules (common code errors e.g. unused imports)
    "COM",     # Standardise trailing commas
]

[tool.ruff.lint.per-file-ignores]
"test_*.py" = [
    "ANN201",  # Don't require "-> None" on every test function
]
"__init__.py" = [
    "F403",    # Allow wildcard imports in __init__.py (__all__ should be defined in such imported modules)
]

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

[tool.ruff.lint.flake8-annotations]
suppress-dummy-args = true
