Skip to content

Commit 907e87a

Browse files
authored
Use ruff instead of black and reorder-python-imports (#239)
Unfortunately black and reorder-python-imports are no longer compatible between each other: asottile/reorder-python-imports#367 asottile/reorder-python-imports#366 psf/black#4175 Take this opportunity to try out ruff. Closes #231
1 parent 001d2c0 commit 907e87a

File tree

7 files changed

+19
-16
lines changed

7 files changed

+19
-16
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ repos:
33
rev: v2.2.6
44
hooks:
55
- id: codespell
6-
- repo: https://github.com/psf/black
7-
rev: 23.11.0
8-
hooks:
9-
- id: black
106
- repo: https://github.com/asottile/blacken-docs
117
rev: 1.16.0
128
hooks:
@@ -23,11 +19,13 @@ repos:
2319
hooks:
2420
- id: pyupgrade
2521
args: [--py37-plus]
26-
- repo: https://github.com/asottile/reorder-python-imports
27-
rev: v3.12.0
22+
- repo: https://github.com/astral-sh/ruff-pre-commit
23+
rev: v0.1.14
2824
hooks:
29-
- id: reorder-python-imports
30-
args: ['--application-directories=execnet', --py37-plus]
25+
- id: ruff
26+
args: [ --fix ]
27+
exclude: "^doc/"
28+
- id: ruff-format
3129
- repo: https://github.com/PyCQA/doc8
3230
rev: 'v1.1.1'
3331
hooks:

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ testing = [
4545
[project.urls]
4646
Homepage = "https://execnet.readthedocs.io/en/latest/"
4747

48+
[tool.ruff.lint]
49+
ignore = ["E741"]
50+
51+
[tool.ruff.lint.isort]
52+
case-sensitive = true
53+
4854
[tool.hatch.version]
4955
source = "vcs"
5056

src/execnet/gateway_base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ class GatewayReceivedTerminate(Exception):
596596

597597
def geterrortext(excinfo, format_exception=traceback.format_exception, sysex=sysex):
598598
try:
599-
l = format_exception(*excinfo)
599+
l = format_exception(*excinfo) # noqa:E741
600600
errortext = "".join(l)
601601
except sysex:
602602
raise
@@ -633,6 +633,7 @@ class TimeoutError(IOError):
633633

634634
class Channel:
635635
"Communication channel between two Python Interpreter execution points."
636+
636637
RemoteError = RemoteError
637638
TimeoutError = TimeoutError
638639
_INTERNALWAKEUP = 1000
@@ -1543,7 +1544,7 @@ def _save_integral(self, i, short_op, long_op):
15431544
def save_int(self, i):
15441545
self._save_integral(i, opcode.INT, opcode.LONGINT)
15451546

1546-
def save_long(self, l):
1547+
def save_long(self, l): # noqa:E741
15471548
self._save_integral(l, opcode.LONG, opcode.LONGLONG)
15481549

15491550
def save_float(self, flt):

src/execnet/gateway_io.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
44
creates io instances used for gateway io
55
"""
6-
import os
76
import shlex
87
import sys
98

@@ -228,4 +227,4 @@ def control(data):
228227

229228

230229
if __name__ == "__channelexec__":
231-
serve_proxy_io(channel) # type: ignore[name-defined]
230+
serve_proxy_io(channel) # type: ignore[name-defined] # noqa:F821

src/execnet/rsync_remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,4 @@ def receive_directory_structure(path, relcomponents):
114114

115115

116116
if __name__ == "__channelexec__":
117-
serve_rsync(channel) # type: ignore[name-defined]
117+
serve_rsync(channel) # type: ignore[name-defined] # noqa:F821

src/execnet/script/shell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def clientside():
2626
while 1:
2727
r, w, e = select.select(inputlist, [], [])
2828
if sys.stdin in r:
29-
line = raw_input()
29+
line = raw_input() # noqa:F821
3030
sock.sendall(line + "\n")
3131
if sock in r:
3232
line = sock.recv(4096)

testing/test_threadpool.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import sys
32

43
import pytest
54
from execnet.gateway_base import WorkerPool
@@ -61,7 +60,7 @@ def first():
6160

6261

6362
def test_waitfinish_on_reply(pool):
64-
l = []
63+
l = [] # noqa:E741
6564
reply = pool.spawn(lambda: l.append(1))
6665
reply.waitfinish()
6766
assert l == [1]

0 commit comments

Comments
 (0)