Skip to content

Commit 65cd059

Browse files
committed
convert to ruff
1 parent 3a76953 commit 65cd059

6 files changed

Lines changed: 31 additions & 18 deletions

File tree

.flake8

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

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ jobs:
8080
# Run linter / checks
8181
checks:
8282
uses: ewoks-kit/.github/.github/workflows/python-check.yml@main
83+
with:
84+
enable-black: "false"
85+
enable-flake8: "false"
86+
enable-isort: "false"
87+
enable-ruff: "true"
8388

8489
# Build documentation
8590
docs:

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
!.gitignore
44
!.github
55
!.readthedocs.yaml
6-
!.flake8
76

87
# Byte / compiled / optimized
98
*.py[cod]

pyproject.toml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ test = [
3333
]
3434
dev = [
3535
"ewoksppf[test]",
36-
"black >=25",
37-
"flake8 >=4",
36+
"ruff>=0.16.0",
3837
]
3938
doc = [
4039
"ewoksppf[test]",
@@ -57,6 +56,22 @@ omit = ['*/tests/*']
5756
[project.entry-points."ewoks.engines"]
5857
"ppf" = "ewoksppf.engine:PpfWorkflowEngine"
5958

60-
[tool.isort]
61-
profile = "black"
62-
force_single_line = "True"
59+
[tool.ruff.lint]
60+
select = [
61+
"E", # pycodestyle errors
62+
"F", # pyflakes
63+
"I", # isort
64+
"S", # flake8-bandit
65+
]
66+
ignore = [
67+
"E501", # line too long
68+
]
69+
70+
[tool.ruff.lint.per-file-ignores]
71+
"src/ewoksppf/tests/*.py" = [
72+
"S101" # allow asserts
73+
]
74+
75+
[tool.ruff.lint.isort]
76+
force-single-line = true
77+
known-first-party = ["ewoksppf"]

scripts/mapreduce_workflow.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@
44
"""
55

66
import os
7-
import random
87
import time
8+
from random import SystemRandom
99

1010
import numpy
1111
from ewokscore.task import Task
1212
from silx.io import h5py_utils
1313

1414
from ewoksppf import execute_graph
1515

16+
_random = SystemRandom()
17+
1618

1719
class GenerateData(
1820
Task,
1921
input_names=["nblocks", "block_size"],
2022
optional_input_names=["block_index"],
2123
output_names=["image_stack", "block_index", "finished"],
2224
):
23-
2425
def run(self):
2526
t0 = time.perf_counter()
2627
block_index = self.get_input_value("block_index", 0)
@@ -34,7 +35,7 @@ def run(self):
3435
self.outputs.block_index = block_index + 1
3536
self.outputs.finished = self.outputs.block_index >= self.inputs.nblocks
3637
t1 = time.perf_counter()
37-
print(f"{block_size/(t1-t0)} images/sec")
38+
print(f"{block_size / (t1 - t0)} images/sec")
3839

3940

4041
class IntegrateData(
@@ -43,25 +44,23 @@ class IntegrateData(
4344
optional_input_names=["axis", "delay"],
4445
output_names=["pattern_stack", "block_index"],
4546
):
46-
4747
def run(self):
4848
image_axis = self.get_input_value("axis", 0)
4949
self.outputs.pattern_stack = self.inputs.image_stack.sum(axis=image_axis + 1)
5050
self.outputs.block_index = self.inputs.block_index
5151

5252
delay = self.get_input_value("delay", 0)
5353
if delay:
54-
time.sleep(random.uniform(delay, delay * 1.5))
54+
time.sleep(_random.uniform(delay, delay * 1.5))
5555
else:
56-
time.sleep(random.uniform(0, 0.1))
56+
time.sleep(_random.uniform(0, 0.1))
5757

5858

5959
class SaveData(
6060
Task,
6161
input_names=["data_stack", "block_index", "filename"],
6262
output_names=["hdf5_url"],
6363
):
64-
6564
def run(self):
6665
filename = os.path.abspath(self.inputs.filename)
6766
block_index = self.inputs.block_index

src/ewoksppf/engine.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111

1212
class PpfWorkflowEngine(WorkflowEngine):
13-
1413
def execute_graph(
1514
self,
1615
graph: Any,

0 commit comments

Comments
 (0)