Skip to content

Commit ea3d273

Browse files
committed
Using ruff instead of black and isort
1 parent 78e63be commit ea3d273

File tree

7 files changed

+62
-22
lines changed

7 files changed

+62
-22
lines changed

.isort.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@
1414
"files.trimTrailingWhitespace": true,
1515
"python.defaultInterpreterPath": "${env:CDL_PYTHONEXE}",
1616
"editor.formatOnSave": true,
17-
"isort.args": [
18-
"--profile",
19-
"black"
20-
],
17+
"python.analysis.autoFormatStrings": true,
18+
"python.testing.unittestEnabled": false,
19+
"python.testing.pytestEnabled": true,
20+
"python.testing.pytestPath": "pytest",
21+
"python.testing.pytestArgs": [],
2122
"[python]": {
22-
"editor.codeActionsOnSave": {
23-
"source.organizeImports": "explicit"
24-
},
25-
"editor.defaultFormatter": "ms-python.black-formatter"
23+
"editor.defaultFormatter": "charliermarsh.ruff"
2624
},
27-
"python.analysis.autoFormatStrings": true,
2825
}

.vscode/tasks.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,34 @@
8989
"clear": true
9090
}
9191
},
92+
{
93+
"label": "Run Ruff",
94+
"type": "shell",
95+
"command": "cmd",
96+
"args": [
97+
"/c",
98+
"run_ruff.bat",
99+
],
100+
"options": {
101+
"cwd": "scripts",
102+
"env": {
103+
"PYTHON": "${env:CDL_PYTHONEXE}",
104+
"UNATTENDED": "1"
105+
}
106+
},
107+
"group": {
108+
"kind": "build",
109+
"isDefault": true
110+
},
111+
"presentation": {
112+
"echo": true,
113+
"reveal": "always",
114+
"focus": false,
115+
"panel": "dedicated",
116+
"showReuseMessage": true,
117+
"clear": true
118+
}
119+
},
92120
{
93121
"label": "Run Coverage",
94122
"type": "shell",

cdlclient/config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
from __future__ import annotations
1414

15-
import os.path as osp
16-
1715
from guidata import configtools
1816

1917
MOD_NAME = "cdlclient"

cdlclient/tests/remoteclient_base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,3 @@ def add_images(self):
147147
@abc.abstractmethod
148148
def remove_all(self):
149149
"""Remove all objects from DataLab"""
150-
151-
def remove_all(self):
152-
"""Remove all objects from DataLab"""

pyproject.toml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Documentation = "https://cdlclient.readthedocs.io/en/latest/"
4747
cdlclient-tests = "cdlclient.tests:run"
4848

4949
[project.optional-dependencies]
50-
dev = ["black", "isort", "pylint", "Coverage"]
50+
dev = ["ruff", "pylint", "Coverage"]
5151
doc = ["sphinx", "sphinx_intl", "pydata-sphinx-theme"]
5252
test = ["PyQt5", "QtPy", "plotpy"]
5353

@@ -59,3 +59,27 @@ include = ["cdlclient*"]
5959

6060
[tool.setuptools.dynamic]
6161
version = { attr = "cdlclient.__version__" }
62+
63+
[tool.ruff]
64+
exclude = [".git", ".vscode", "build", "dist"]
65+
line-length = 88 # Same as Black.
66+
indent-width = 4 # Same as Black.
67+
target-version = "py38" # Assume Python 3.8
68+
69+
[tool.ruff.lint]
70+
# all rules can be found here: https://beta.ruff.rs/docs/rules/
71+
select = ["E", "F", "W", "I"]
72+
ignore = [
73+
"E203", # space before : (needed for how black formats slicing)
74+
]
75+
76+
[tool.ruff.format]
77+
quote-style = "double" # Like Black, use double quotes for strings.
78+
indent-style = "space" # Like Black, indent with spaces, rather than tabs.
79+
skip-magic-trailing-comma = false # Like Black, respect magic trailing commas.
80+
line-ending = "auto" # Like Black, automatically detect the appropriate line ending.
81+
82+
[tool.ruff.lint.per-file-ignores]
83+
"doc/*" = ["E402"]
84+
"svg_icons.py" = ["E501"]
85+
"datalab_banner.py" = ["E501", "W292"]
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
@echo off
22
REM This script was derived from PythonQwt project
33
REM ======================================================
4-
REM Run black and isort code analysis tool
4+
REM Run Ruff analysis
55
REM ======================================================
66
REM Licensed under the terms of the MIT License
77
REM Copyright (c) 2020 Pierre Raybaut
88
REM (see PythonQwt LICENSE file for more details)
99
REM ======================================================
1010
setlocal
1111
call %~dp0utils GetScriptPath SCRIPTPATH
12-
call %FUNC% GetLibName LIBNAME
12+
call %FUNC% GetModName MODNAME
1313
call %FUNC% SetPythonPath
14-
set PYTHON=%CDL_PYTHONEXE%
1514
call %FUNC% UsePython
16-
python -m black .
17-
python -m isort --profile black .
15+
ruff check
1816
call %FUNC% EndOfScript

0 commit comments

Comments
 (0)