From bd06a59ae912e71947609476a5fc11a439b07672 Mon Sep 17 00:00:00 2001 From: "Xuefeng Ding (IHEP)" <dingxf@ihep.ac.cn> Date: Wed, 20 Nov 2024 14:07:17 +0800 Subject: [PATCH] update by ruff --- .pre-commit-config.yaml | 37 +------------------------------------ notebooks/example.ipynb | 5 ++--- pyproject.toml | 10 ++++++++++ 3 files changed, 13 insertions(+), 39 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 95b947a..2dff7dc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,27 +30,11 @@ repos: - id: clang-format types_or: [c++, c, cuda] - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.10.0 # Use the latest stable version - hooks: - - id: black-jupyter - - - repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort - name: isort (python) - - - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: "v1.5.5" - hooks: - - id: remove-tabs - - repo: https://github.com/charliermarsh/ruff-pre-commit rev: v0.7.4 # Use the latest version hooks: - id: ruff - args: ["--fix", "--show-fixes"] + args: ["--fix", "--exit-non-zero-on-fix", "--show-fixes"] - repo: https://github.com/cheshirekow/cmake-format-precommit rev: v0.6.13 @@ -58,22 +42,3 @@ repos: - id: cmake-format types: [file] files: (\.cmake|CMakeLists.txt)(.in)?$ - - # - repo: https://github.com/codespell-project/codespell - # rev: v - # hooks: - # - id: codespell - # args: ["-L", "sur,falsy,gaus,hist,lsit,nd,parms,retur,ue,ba,claus,fo"] - - # - repo: https://github.com/pre-commit/pygrep-hooks - # rev: v - # hooks: - # - id: rst-backticks - # - id: rst-directive-colons - # - id: rst-inline-touching-normal - - # - repo: https://github.com/shellcheck-py/shellcheck-py - # rev: v0.9.0.5 - # hooks: - # - id: shellcheck - # stages: [manual] diff --git a/notebooks/example.ipynb b/notebooks/example.ipynb index 4952e58..d9eedf5 100644 --- a/notebooks/example.ipynb +++ b/notebooks/example.ipynb @@ -48,8 +48,7 @@ "import pylint.lint\n", "from pylint.reporters import JSONReporter\n", "\n", - "# Adjust PYTHONPATH\n", - "# sys.path.append('/datafs/users/dingxf/neutrino-physics-tutorial/scikit-build-cpp-python')\n", + "root = \"/datafs/users/dingxf/neutrino-physics-tutorial/scikit-build-cpp-python\"\n", "\n", "# Define the Pylint options\n", "pylint_options = [\n", @@ -58,7 +57,7 @@ " \"--extension-pkg-allow-list=simulation._csrc._hello\",\n", " \"--prefer-stubs=true\",\n", " \"--clear-cache-post-run=y\",\n", - " \"/datafs/users/dingxf/neutrino-physics-tutorial/scikit-build-cpp-python/python/myproj/simulation/core.py\", # The file you want to lint\n", + " f\"{root}/python/myproj/simulation/core.py\", # The file you want to lint\n", "]\n", "\n", "# Create a StringIO buffer to capture Pylint output\n", diff --git a/pyproject.toml b/pyproject.toml index 4edd520..7c1f46e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,3 +67,13 @@ disable = [ [tool.pylint.MASTER] extension-pkg-allow-list = "myproj.simulation" + +[tool.ruff.lint] +select = [ + "E", # pycodestyle + "F", # Pyflakes + "UP", # pyupgrade + "B", # flake8-bugbear + "SIM", # flake8-simplify + "I", # isort +] -- GitLab