Skip to content

Commit 7d9a9fe

Browse files
committed
Using ruff instead of black and isort
1 parent c2ad753 commit 7d9a9fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+235
-165
lines changed

.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-
],
39-
"python.analysis.autoFormatStrings": true,
40-
"editor.defaultFoldingRangeProvider": "ms-python.black-formatter",
41-
"editor.defaultFormatter": "ms-python.black-formatter",
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
@@ -141,6 +141,34 @@
141141
"clear": true
142142
}
143143
},
144+
{
145+
"label": "Run Ruff",
146+
"type": "shell",
147+
"command": "cmd",
148+
"args": [
149+
"/c",
150+
"run_ruff.bat",
151+
],
152+
"options": {
153+
"cwd": "scripts",
154+
"env": {
155+
"PYTHON": "${env:PPSTACK_PYTHONEXE}",
156+
"UNATTENDED": "1"
157+
}
158+
},
159+
"group": {
160+
"kind": "build",
161+
"isDefault": true
162+
},
163+
"presentation": {
164+
"echo": true,
165+
"reveal": "always",
166+
"focus": false,
167+
"panel": "dedicated",
168+
"showReuseMessage": true,
169+
"clear": true
170+
}
171+
},
144172
{
145173
"label": "Build documentation",
146174
"type": "shell",

conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""pytest configuration for PythonQwt package tests."""
44

55
import os
6+
67
from qwt.tests.utils import TestEnvironment
78

89
# Set the unattended environment variable to 1 to avoid any user interaction

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
2222
extensions = ["sphinx.ext.autodoc"]
2323
try:
24-
import sphinx.ext.viewcode
24+
import sphinx.ext.viewcode # noqa: F401
2525

2626
extensions.append("sphinx.ext.viewcode")
2727
except ImportError:

doc/plot_example.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212
plot.insertLegend(qwt.QwtLegend(), qwt.QwtPlot.BottomLegend)
1313
qwt.QwtPlotCurve.make(x, np.cos(x), "Cosinus", plot, linecolor="red", antialiased=True)
1414
qwt.QwtPlotCurve.make(x, np.sin(x), "Sinus", plot, linecolor="blue", antialiased=True)
15-
qth.take_screenshot(plot, osp.join(osp.abspath(osp.dirname(__file__)), "_static", "QwtPlot_example.png"), size=(600, 300))
15+
qth.take_screenshot(
16+
plot,
17+
osp.join(osp.abspath(osp.dirname(__file__)), "_static", "QwtPlot_example.png"),
18+
size=(600, 300),
19+
)

doc/symbol_path_example.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
from qtpy import QtWidgets as QW
2-
from qtpy import QtGui as QG
1+
import os.path as osp
2+
3+
import numpy as np
34
from qtpy import QtCore as QC
5+
from qtpy import QtGui as QG
6+
from qtpy import QtWidgets as QW
7+
48
import qwt
5-
import numpy as np
6-
import os.path as osp
79
from qwt import qthelpers as qth
810

911
app = QW.QApplication([])
@@ -46,4 +48,8 @@
4648
curve.attach(plot)
4749
plot.replot()
4850

49-
qth.take_screenshot(plot, osp.join(osp.abspath(osp.dirname(__file__)), "_static", "symbol_path_example.png"), size=(600, 300))
51+
qth.take_screenshot(
52+
plot,
53+
osp.join(osp.abspath(osp.dirname(__file__)), "_static", "symbol_path_example.png"),
54+
size=(600, 300),
55+
)

pyproject.toml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Documentation = "https://PythonQwt.readthedocs.io/en/latest/"
4242
PythonQwt-tests = "qwt.tests:run"
4343

4444
[project.optional-dependencies]
45-
dev = ["black", "isort", "pylint", "Coverage"]
45+
dev = ["ruff", "pylint", "Coverage"]
4646
doc = ["PyQt5", "sphinx>6", "python-docs-theme"]
4747
test = ["pytest", "pytest-xvfb"]
4848

@@ -54,3 +54,26 @@ include = ["qwt*"]
5454

5555
[tool.setuptools.dynamic]
5656
version = { attr = "qwt.__version__" }
57+
58+
[tool.ruff]
59+
exclude = [".git", ".vscode", "build", "dist"]
60+
line-length = 88 # Same as Black.
61+
indent-width = 4 # Same as Black.
62+
target-version = "py38" # Assume Python 3.8
63+
64+
[tool.ruff.lint]
65+
# all rules can be found here: https://beta.ruff.rs/docs/rules/
66+
select = ["E", "F", "W", "I"]
67+
ignore = [
68+
"E203", # space before : (needed for how black formats slicing)
69+
]
70+
71+
[tool.ruff.format]
72+
quote-style = "double" # Like Black, use double quotes for strings.
73+
indent-style = "space" # Like Black, indent with spaces, rather than tabs.
74+
skip-magic-trailing-comma = false # Like Black, respect magic trailing commas.
75+
line-ending = "auto" # Like Black, automatically detect the appropriate line ending.
76+
77+
[tool.ruff.lint.per-file-ignores]
78+
"doc/*" = ["E402"]
79+
"qwt/tests/*" = ["E402"]

qwt/__init__.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,36 @@
2727
.. _GitHub: https://github.com/PlotPyStack/PythonQwt
2828
"""
2929

30-
__version__ = "0.12.2"
31-
QWT_VERSION_STR = "6.1.5"
32-
3330
import warnings
3431

35-
from qwt.color_map import QwtLinearColorMap
32+
from qwt.color_map import QwtLinearColorMap # noqa: F401
3633
from qwt.interval import QwtInterval
37-
from qwt.legend import QwtLegend, QwtLegendData, QwtLegendLabel
38-
from qwt.painter import QwtPainter
39-
from qwt.plot import QwtPlot
40-
from qwt.plot_canvas import QwtPlotCanvas
34+
from qwt.legend import QwtLegend, QwtLegendData, QwtLegendLabel # noqa: F401
35+
from qwt.painter import QwtPainter # noqa: F401
36+
from qwt.plot import QwtPlot # noqa: F401
37+
from qwt.plot_canvas import QwtPlotCanvas # noqa: F401
4138
from qwt.plot_curve import QwtPlotCurve as QPC # see deprecated section
42-
from qwt.plot_curve import QwtPlotItem
43-
from qwt.plot_directpainter import QwtPlotDirectPainter
39+
from qwt.plot_curve import QwtPlotItem # noqa: F401
40+
from qwt.plot_directpainter import QwtPlotDirectPainter # noqa: F401
4441
from qwt.plot_grid import QwtPlotGrid as QPG # see deprecated section
45-
from qwt.plot_marker import QwtPlotMarker
46-
from qwt.plot_renderer import QwtPlotRenderer
47-
from qwt.plot_series import (
42+
from qwt.plot_marker import QwtPlotMarker # noqa: F401
43+
from qwt.plot_renderer import QwtPlotRenderer # noqa: F401
44+
from qwt.plot_series import ( # noqa: F401
4845
QwtPlotSeriesItem,
4946
QwtPointArrayData,
5047
QwtSeriesData,
5148
QwtSeriesStore,
5249
)
53-
from qwt.scale_div import QwtScaleDiv
54-
from qwt.scale_draw import QwtAbstractScaleDraw, QwtScaleDraw
55-
from qwt.scale_engine import QwtLinearScaleEngine, QwtLogScaleEngine
56-
from qwt.scale_map import QwtScaleMap
50+
from qwt.scale_div import QwtScaleDiv # noqa: F401
51+
from qwt.scale_draw import QwtAbstractScaleDraw, QwtScaleDraw # noqa: F401
52+
from qwt.scale_engine import QwtLinearScaleEngine, QwtLogScaleEngine # noqa: F401
53+
from qwt.scale_map import QwtScaleMap # noqa: F401
5754
from qwt.symbol import QwtSymbol as QSbl # see deprecated section
58-
from qwt.text import QwtText
59-
from qwt.toqimage import array_to_qimage as toQImage
55+
from qwt.text import QwtText # noqa: F401
56+
from qwt.toqimage import array_to_qimage as toQImage # noqa: F401
57+
58+
__version__ = "0.12.2"
59+
QWT_VERSION_STR = "6.1.5"
6060

6161

6262
## ============================================================================

qwt/_math.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
# Copyright (c) 2015 Pierre Raybaut, for the Python translation/optimization
66
# (see LICENSE file for more details)
77

8-
from qtpy.QtCore import qFuzzyCompare
9-
108
import math
119

10+
from qtpy.QtCore import qFuzzyCompare
11+
1212

1313
def qwtFuzzyCompare(value1, value2, intervalSize):
1414
eps = abs(1.0e-6 * intervalSize)
@@ -38,16 +38,16 @@ def qwtSign(x):
3838

3939

4040
def qwtSqr(x):
41-
return x ** 2
41+
return x**2
4242

4343

4444
def qwtFastAtan(x):
4545
if x < -1.0:
46-
return -0.5 * math.pi - x / (x ** 2 + 0.28)
46+
return -0.5 * math.pi - x / (x**2 + 0.28)
4747
elif x > 1.0:
48-
return 0.5 * math.pi - x / (x ** 2 + 0.28)
48+
return 0.5 * math.pi - x / (x**2 + 0.28)
4949
else:
50-
return x / (1.0 + x ** 2 * 0.28)
50+
return x / (1.0 + x**2 * 0.28)
5151

5252

5353
def qwtFastAtan2(y, x):

0 commit comments

Comments
 (0)