Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ adopt ruff formatter and update ruff config #324

Merged
merged 1 commit into from
Oct 30, 2023
Merged
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
16 changes: 6 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 and formatting 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
Expand Down
21 changes: 9 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ report.exclude_also = [
'if TYPE_CHECKING:',
]

[tool.black]
line-length = 120


[tool.mypy]
files = ["src/mqt", "test/python"]
Expand All @@ -170,9 +167,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
Expand Down Expand Up @@ -211,16 +213,11 @@ select = [
]
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
]
src = ["src"]
flake8-unused-arguments.ignore-variadic-names = true
isort.required-imports = ["from __future__ import annotations"]
line-length = 120

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"*.pyi" = ["D"] # pydocstyle
"*.ipynb" = [
"D", # pydocstyle
Expand Down
6 changes: 3 additions & 3 deletions src/mqt/qcec/pyqcec/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ApplicationScheme:
def __eq__(self, other: object) -> bool: ...
def __getstate__(self) -> int: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
def __index__(self) -> int: ... # noqa: PLW3201
def __int__(self) -> int: ...
def __ne__(self, other: object) -> bool: ...
def __setstate__(self, state: int) -> None: ...
Expand Down Expand Up @@ -150,7 +150,7 @@ class EquivalenceCriterion:
def __eq__(self, other: object) -> bool: ...
def __getstate__(self) -> int: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
def __index__(self) -> int: ... # noqa: PLW3201
def __int__(self) -> int: ...
def __ne__(self, other: object) -> bool: ...
def __setstate__(self, state: int) -> None: ...
Expand All @@ -171,7 +171,7 @@ class StateType:
def __eq__(self, other: object) -> bool: ...
def __getstate__(self) -> int: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
def __index__(self) -> int: ... # noqa: PLW3201
def __int__(self) -> int: ...
def __ne__(self, other: object) -> bool: ...
def __setstate__(self, state: int) -> None: ...
Expand Down