Skip to content

Commit

Permalink
Use ruff instead of black and reorder-python-imports (#239)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nicoddemus committed Jan 30, 2024
1 parent 001d2c0 commit 907e87a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
14 changes: 6 additions & 8 deletions .pre-commit-config.yaml
Expand Up @@ -3,10 +3,6 @@ repos:
rev: v2.2.6
hooks:
- id: codespell
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
Expand All @@ -23,11 +19,13 @@ repos:
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
hooks:
- id: reorder-python-imports
args: ['--application-directories=execnet', --py37-plus]
- id: ruff
args: [ --fix ]
exclude: "^doc/"
- id: ruff-format
- repo: https://github.com/PyCQA/doc8
rev: 'v1.1.1'
hooks:
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Expand Up @@ -45,6 +45,12 @@ testing = [
[project.urls]
Homepage = "https://execnet.readthedocs.io/en/latest/"

[tool.ruff.lint]
ignore = ["E741"]

[tool.ruff.lint.isort]
case-sensitive = true

[tool.hatch.version]
source = "vcs"

Expand Down
5 changes: 3 additions & 2 deletions src/execnet/gateway_base.py
Expand Up @@ -596,7 +596,7 @@ class GatewayReceivedTerminate(Exception):

def geterrortext(excinfo, format_exception=traceback.format_exception, sysex=sysex):
try:
l = format_exception(*excinfo)
l = format_exception(*excinfo) # noqa:E741
errortext = "".join(l)
except sysex:
raise
Expand Down Expand Up @@ -633,6 +633,7 @@ class TimeoutError(IOError):

class Channel:
"Communication channel between two Python Interpreter execution points."

RemoteError = RemoteError
TimeoutError = TimeoutError
_INTERNALWAKEUP = 1000
Expand Down Expand Up @@ -1543,7 +1544,7 @@ def _save_integral(self, i, short_op, long_op):
def save_int(self, i):
self._save_integral(i, opcode.INT, opcode.LONGINT)

def save_long(self, l):
def save_long(self, l): # noqa:E741
self._save_integral(l, opcode.LONG, opcode.LONGLONG)

def save_float(self, flt):
Expand Down
3 changes: 1 addition & 2 deletions src/execnet/gateway_io.py
Expand Up @@ -3,7 +3,6 @@
creates io instances used for gateway io
"""
import os
import shlex
import sys

Expand Down Expand Up @@ -228,4 +227,4 @@ def control(data):


if __name__ == "__channelexec__":
serve_proxy_io(channel) # type: ignore[name-defined]
serve_proxy_io(channel) # type: ignore[name-defined] # noqa:F821
2 changes: 1 addition & 1 deletion src/execnet/rsync_remote.py
Expand Up @@ -114,4 +114,4 @@ def receive_directory_structure(path, relcomponents):


if __name__ == "__channelexec__":
serve_rsync(channel) # type: ignore[name-defined]
serve_rsync(channel) # type: ignore[name-defined] # noqa:F821
2 changes: 1 addition & 1 deletion src/execnet/script/shell.py
Expand Up @@ -26,7 +26,7 @@ def clientside():
while 1:
r, w, e = select.select(inputlist, [], [])
if sys.stdin in r:
line = raw_input()
line = raw_input() # noqa:F821
sock.sendall(line + "\n")
if sock in r:
line = sock.recv(4096)
Expand Down
3 changes: 1 addition & 2 deletions testing/test_threadpool.py
@@ -1,5 +1,4 @@
import os
import sys

import pytest
from execnet.gateway_base import WorkerPool
Expand Down Expand Up @@ -61,7 +60,7 @@ def first():


def test_waitfinish_on_reply(pool):
l = []
l = [] # noqa:E741
reply = pool.spawn(lambda: l.append(1))
reply.waitfinish()
assert l == [1]
Expand Down

0 comments on commit 907e87a

Please sign in to comment.