diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 03883b5f73609..0000000000000 --- a/.flake8 +++ /dev/null @@ -1,13 +0,0 @@ -[flake8] -exclude = - .venv - __pycache__ - notebooks - .ipynb_checkpoints - examples -# Recommend matching the black line length (default 88), -# rather than using the flake8 default of 79: -max-line-length = 88 -extend-ignore = - # See https://github.com/PyCQA/pycodestyle/issues/373 - E203, diff --git a/.gitignore b/.gitignore index f888afc8f4631..0900a937e6bbf 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ coverage.xml *.py,cover .hypothesis/ .pytest_cache/ +.ruff_cache # Translations *.mo diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000000..7e43d3b057d0e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,5 @@ +repos: + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.243 + hooks: + - id: ruff diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ab185fe3db684..4dcd73cfe1a9d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,7 +53,13 @@ You can format and lint your changes with the following commands in the root dir make format; make lint ``` -We run an assortment of linters: `black`, `isort`, `mypy`, `flake8`. +You can also make use of our pre-commit hooks by setting up git hook scripts: + +```bash +pre-commit install +``` + +We run an assortment of linters: `black`, `ruff`, `mypy`. ### Testing diff --git a/Makefile b/Makefile index 11f224f37191e..eb1e3c09ab32b 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,11 @@ format: black . - isort . lint: mypy . black . --check - isort . --check - flake8 . + ruff check . test: - pytest tests \ No newline at end of file + pytest tests diff --git a/pyproject.toml b/pyproject.toml index dd8bdcdb7fe30..8e44e5b0c360b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,15 @@ -[tool.isort] -profile = "black" - [tool.mypy] ignore_missing_imports = "True" disallow_untyped_defs = "True" exclude = ["notebooks", "build", "examples"] + +[tool.ruff] +exclude = [ + ".venv", + "__pycache__", + ".ipynb_checkpoints", + ".mypy_cache", + ".ruff_cache", + "examples", + "notebooks", +] diff --git a/requirements.txt b/requirements.txt index fc1e2aeaf7c65..f58524987425f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,8 +14,7 @@ types-setuptools==67.1.0.0 # linting black==22.12.0 -isort==5.11.4 mypy==0.991 -flake8==6.0.0 -flake8-docstrings==1.6.0 +pre-commit==3.2.0 pylint==2.15.10 +ruff==0.0.259 \ No newline at end of file