diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml old mode 100755 new mode 100644 index fbc6dbb46f7..89d1cbf7396 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,3 +41,8 @@ repos: entry: python .pre-commit-hooks/convert_markdown_into_html.py language: system files: .+README(\.cn)?\.md$ +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.1 + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix, --no-cache] diff --git a/pyproject.toml b/pyproject.toml index e9513d0648b..bf1f56150f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,3 +2,98 @@ exclude = "build" line-length = 80 skip-string-normalization = true + +[tool.ruff] +target-version = "py37" +select = [ + # Pycodestyle + "E", + "W", + + # Pyflakes + "F", + + # Isort + "I", + + # Comprehensions + "C4", + + # Pyupgrade + "UP", + + # NumPy-specific rules + "NPY001", + "NPY003", + + # Bugbear + "B002", + "B003", + "B004", + "B009", + "B010", + "B011", + "B012", + "B013", + "B014", + "B015", + "B016", + "B017", + "B018", + "B019", + "B020", + "B021", + "B022", + "B025", + "B029", + "B032", + + # Pylint + "PLE", + "PLC0414", + "PLC3002", + "PLR0206", + "PLR0402", + "PLR1701", + "PLR1711", + "PLR1722", + "PLW3301", + + # Pygrep-hooks + "PGH004", +] +unfixable = [ + "NPY001" +] +ignore = [ + "E402", + "E501", + "E722", + "E731", + "E741", + "F841", + "UP015", + "UP038", + # need to remove + "F541", + "I001", + "UP032", + "F401", + "UP025", + "W291", + "PLR1722", + "C403", + "C405", + "UP004", + "UP008", + "C414", + "C416", + "C419", + "E401", + "E711", + "E712", + "F811", + "F821", + "PLR1701", + "UP031" +]