diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 33fbfcc2..c9cbb8d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,26 +49,22 @@ repos: - id: rst-directive-colons - id: rst-inline-touching-normal - # Run ruff (subsumes pyupgrade, isort, flake8+plugins, and more) + # Python linting using ruff - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.1 + rev: v0.1.3 hooks: - id: ruff args: ["--fix", "--show-fixes"] - - # Run code formatting with Black - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.10.0 # Keep in sync with blacken-docs - hooks: - - id: black-jupyter + types_or: [python, pyi, jupyter] + - id: ruff-format + types_or: [python, pyi, jupyter] # Also run Black on examples in the documentation - repo: https://github.com/adamchainz/blacken-docs rev: 1.16.0 hooks: - id: blacken-docs - additional_dependencies: - - black==23.10.0 # keep in sync with black hook + additional_dependencies: [black==23.*] # CMake format and lint the CMakeLists.txt files - repo: https://github.com/cheshirekow/cmake-format-precommit diff --git a/docs/source/Usage.ipynb b/docs/source/Usage.ipynb index 14b531ff..6098c8c0 100644 --- a/docs/source/Usage.ipynb +++ b/docs/source/Usage.ipynb @@ -41,6 +41,7 @@ "outputs": [], "source": [ "from qiskit import QuantumCircuit\n", + "\n", "from mqt.ddsim import CircuitSimulator\n", "\n", "# A simple circuit that creates a Bell state\n", @@ -154,7 +155,7 @@ "metadata": {}, "outputs": [], "source": [ - "from qiskit import *\n", + "from qiskit import QuantumCircuit, execute\n", "\n", "from mqt import ddsim\n", "\n", diff --git a/pyproject.toml b/pyproject.toml index 3ac5e2a1..373d322e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -154,9 +154,6 @@ report.exclude_also = [ 'if TYPE_CHECKING:', ] -[tool.black] -line-length = 120 - [tool.mypy] files = ["src/mqt", "test/python"] @@ -174,9 +171,14 @@ module = ["qiskit.*"] ignore_missing_imports = true [tool.ruff] -include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"] -select = [ - "E", "F", "W", # flake8 +line-length = 120 +extend-include = ["*.ipynb"] +src = ["src"] +preview = true +unsafe-fixes = true + +[tool.ruff.lint] +extend-select = [ "A", # flake8-builtins # "ANN", # flake8-annotations "ARG", # flake8-unused-arguments @@ -214,15 +216,9 @@ select = [ "YTT", # flake8-2020 ] extend-ignore = [ - "ANN101", # Missing type annotation for self in method - "ANN102", # Missing type annotation for cls in classmethod - "E501", # Line too long (Black is enough) - "PLR", # Design related pylint codes + "PLR", # Design related pylint codes ] -src = ["src"] -flake8-unused-arguments.ignore-variadic-names = true isort.required-imports = ["from __future__ import annotations"] -line-length = 120 [tool.ruff.per-file-ignores] "*.pyi" = ["D"] # pydocstyle diff --git a/test/python/unitarysimulator/test_standalone_unitary_simulator.py b/test/python/unitarysimulator/test_standalone_unitary_simulator.py index 84f1f1d1..de3dc6a5 100644 --- a/test/python/unitarysimulator/test_standalone_unitary_simulator.py +++ b/test/python/unitarysimulator/test_standalone_unitary_simulator.py @@ -16,9 +16,7 @@ def setUp(self) -> None: circ.cx(0, 1) circ.cx(0, 2) self.circuit = circ - self.unitary: npt.NDArray[np.complex_] = np.zeros( - (2**circ.num_qubits, 2**circ.num_qubits), dtype=np.complex_ - ) + self.unitary: npt.NDArray[np.complex_] = np.zeros((2**circ.num_qubits, 2**circ.num_qubits), dtype=np.complex_) self.non_zeros_in_bell_circuit = 16 def test_standalone_sequential_mode(self):