Skip to content

Commit f665ad7

Browse files
committed
Using ruff instead of black and isort
1 parent 5c8ec26 commit f665ad7

27 files changed

Lines changed: 106 additions & 69 deletions

.isort.cfg

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

.vscode/settings.json

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,12 @@
1818
"files.trimTrailingWhitespace": true,
1919
"python.defaultInterpreterPath": "${env:PPSTACK_PYTHONEXE}",
2020
"editor.formatOnSave": true,
21-
"isort.args": [
22-
"--profile",
23-
"black"
24-
],
25-
"[python]": {
26-
"editor.codeActionsOnSave": {
27-
"source.organizeImports": "explicit"
28-
},
29-
"editor.defaultFormatter": "ms-python.black-formatter"
30-
},
21+
"python.analysis.autoFormatStrings": true,
3122
"python.testing.unittestEnabled": false,
3223
"python.testing.pytestEnabled": true,
3324
"python.testing.pytestPath": "pytest",
34-
"python.testing.pytestArgs": [
35-
"-v",
36-
"--cov",
37-
"--cov-report=html",
38-
"plotpy"
39-
],
40-
"python.analysis.autoFormatStrings": true,
41-
"python.analysis.typeCheckingMode": "off",
25+
"python.testing.pytestArgs": [],
26+
"[python]": {
27+
"editor.defaultFormatter": "charliermarsh.ruff"
28+
},
4229
}

.vscode/tasks.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,34 @@
149149
"clear": true
150150
}
151151
},
152+
{
153+
"label": "Run Ruff",
154+
"type": "shell",
155+
"command": "cmd",
156+
"args": [
157+
"/c",
158+
"run_ruff.bat",
159+
],
160+
"options": {
161+
"cwd": "scripts",
162+
"env": {
163+
"PYTHON": "${env:PPSTACK_PYTHONEXE}",
164+
"UNATTENDED": "1"
165+
}
166+
},
167+
"group": {
168+
"kind": "build",
169+
"isDefault": true
170+
},
171+
"presentation": {
172+
"echo": true,
173+
"reveal": "always",
174+
"focus": false,
175+
"panel": "dedicated",
176+
"showReuseMessage": true,
177+
"clear": true
178+
}
179+
},
152180
{
153181
"label": "Clean Up",
154182
"type": "shell",

doc/dev/build.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ To run test with coverage support, use the following command::
3939
Code formatting
4040
^^^^^^^^^^^^^^^
4141

42-
The code is formatted with `black <https://black.readthedocs.io/en/stable/>`_
43-
and `isort <https://isort.readthedocs.io/en/stable/>`_.
42+
The code is formatted with `ruff <https://pypi.org/project/ruff/>`_.
4443

4544
If you are using `Visual Studio Code <https://code.visualstudio.com/>`_,
4645
the formatting is done automatically when you save a file, thanks to the

doc/intro/motivation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ What are PlotPy V2 advantages over PlotPy V1?
99
From a developer point of view, PlotPy V2 is a major overhaul of PlotPy V1:
1010

1111
* Architecture has been redesigned to be more modular and extensible, and more simple.
12-
* Code quality has been improved introducing `black`, `isort` and typing annotations
12+
* Code quality has been improved introducing `ruff` and typing annotations
1313
all over the codebase
1414

1515
.. note::

plotpy/external/sliders/_labeled.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
)
2323

2424
from ._misc import signals_blocked
25-
2625
from ._sliders import QDoubleRangeSlider, QDoubleSlider, QRangeSlider
2726

2827

@@ -133,14 +132,12 @@ class QLabeledSlider(_SliderProxy, QAbstractSlider):
133132
_slider: QSlider
134133

135134
@overload
136-
def __init__(self, parent: QWidget | None = ...) -> None:
137-
...
135+
def __init__(self, parent: QWidget | None = ...) -> None: ...
138136

139137
@overload
140138
def __init__(
141139
self, orientation: Qt.Orientation, parent: QWidget | None = ...
142-
) -> None:
143-
...
140+
) -> None: ...
144141

145142
def __init__(self, *args: Any, **kwargs: Any) -> None:
146143
parent, orientation = _handle_overloaded_slider_sig(args, kwargs)
@@ -263,14 +260,12 @@ class QLabeledDoubleSlider(QLabeledSlider):
263260
_frangeChanged = Signal(float, float)
264261

265262
@overload
266-
def __init__(self, parent: QWidget | None = ...) -> None:
267-
...
263+
def __init__(self, parent: QWidget | None = ...) -> None: ...
268264

269265
@overload
270266
def __init__(
271267
self, orientation: Qt.Orientation, parent: QWidget | None = ...
272-
) -> None:
273-
...
268+
) -> None: ...
274269

275270
def __init__(self, *args: Any, **kwargs: Any) -> None:
276271
super().__init__(*args, **kwargs)
@@ -300,14 +295,12 @@ class QLabeledRangeSlider(_SliderProxy, QAbstractSlider):
300295
_slider: QRangeSlider
301296

302297
@overload
303-
def __init__(self, parent: QWidget | None = ...) -> None:
304-
...
298+
def __init__(self, parent: QWidget | None = ...) -> None: ...
305299

306300
@overload
307301
def __init__(
308302
self, orientation: Qt.Orientation, parent: QWidget | None = ...
309-
) -> None:
310-
...
303+
) -> None: ...
311304

312305
def __init__(self, *args: Any, **kwargs: Any) -> None:
313306
parent, orientation = _handle_overloaded_slider_sig(args, kwargs)
@@ -545,14 +538,12 @@ class QLabeledDoubleRangeSlider(QLabeledRangeSlider):
545538
_frangeChanged = Signal(float, float)
546539

547540
@overload
548-
def __init__(self, parent: QWidget | None = ...) -> None:
549-
...
541+
def __init__(self, parent: QWidget | None = ...) -> None: ...
550542

551543
@overload
552544
def __init__(
553545
self, orientation: Qt.Orientation, parent: QWidget | None = ...
554-
) -> None:
555-
...
546+
) -> None: ...
556547

557548
def __init__(self, *args: Any, **kwargs: Any) -> None:
558549
super().__init__(*args, **kwargs)

plotpy/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def _import_dcm():
374374
# is to check if pydicom is installed:
375375
# pylint: disable=import-outside-toplevel
376376
# pylint: disable=import-error
377-
from pydicom import dicomio # type:ignore
377+
from pydicom import dicomio # type:ignore # noqa: F401
378378

379379
logger.setLevel(logging.WARNING)
380380

plotpy/items/label.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ def get_legend_size(
706706
"""
707707
width = 0
708708
height = 0
709-
for text, _, _, _ in legenditems:
709+
for text, _, _, _ in legenditems: # noqa
710710
sz = text.size()
711711
if sz.width() > width:
712712
width = sz.width()

plotpy/tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from guidata.configtools import get_module_data_path
1414

15-
import plotpy
15+
import plotpy # noqa: F401
1616

1717
TESTDATAPATH = get_module_data_path("plotpy", osp.join("tests", "data"))
1818

plotpy/tests/features/test_autoscale_shapes.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
from guidata.qthelpers import qt_app_context
1212

1313
from plotpy.builder import make
14-
from plotpy.items import PolygonShape
1514
from plotpy.plot import PlotDialog
16-
from plotpy.styles import ShapeParam
1715
from plotpy.tools import (
1816
AnnotatedCircleTool,
1917
AnnotatedEllipseTool,

0 commit comments

Comments
 (0)