Skip to content
Snippets Groups Projects
Commit bd06a59a authored by Xuefeng Ding's avatar Xuefeng Ding
Browse files

update by ruff

parent ad628911
No related branches found
No related tags found
No related merge requests found
......@@ -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]
%% Cell type:code id: tags:
``` python
import myproj.simulation as ms
import numpy as np
print(ms.add(1, 2))
print(ms.complex(1, 2))
print(np.array([1, 2, 3]))
```
%% Cell type:code id: tags:
``` python
import pylint
pylint.run_pylint(["myproj/simulation"])
```
%% Cell type:code id: tags:
``` python
from astroid.interpreter._import import util
print(util.is_namespace("myproj"))
```
%% Cell type:code id: tags:
``` python
import json
from io import StringIO
import pylint.lint
from pylint.reporters import JSONReporter
# Adjust PYTHONPATH
# sys.path.append('/datafs/users/dingxf/neutrino-physics-tutorial/scikit-build-cpp-python')
root = "/datafs/users/dingxf/neutrino-physics-tutorial/scikit-build-cpp-python"
# Define the Pylint options
pylint_options = [
"--reports=n",
"--output-format=json",
"--extension-pkg-allow-list=simulation._csrc._hello",
"--prefer-stubs=true",
"--clear-cache-post-run=y",
"/datafs/users/dingxf/neutrino-physics-tutorial/scikit-build-cpp-python/python/myproj/simulation/core.py", # The file you want to lint
f"{root}/python/myproj/simulation/core.py", # The file you want to lint
]
# Create a StringIO buffer to capture Pylint output
pylint_output = StringIO()
reporter = JSONReporter(output=pylint_output)
# Run Pylint
pylint.lint.Run(pylint_options, reporter=reporter, exit=True)
# Get the output
output = pylint_output.getvalue()
# Parse and display the results
results = json.loads(output)
print(json.dumps(results, indent=2))
```
......
......@@ -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
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment