Skip to content

Commit 0c11822

Browse files
committed
Enable more lints
List adapted from pytest's configuration.
1 parent 63cd953 commit 0c11822

15 files changed

+49
-30
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ repos:
1111
- repo: https://github.com/pre-commit/pre-commit-hooks
1212
rev: v4.5.0
1313
hooks:
14-
- id: trailing-whitespace
15-
- id: end-of-file-fixer
1614
- id: check-yaml
17-
- repo: https://github.com/asottile/pyupgrade
18-
rev: v3.15.1
19-
hooks:
20-
- id: pyupgrade
21-
args: [--py38-plus]
2215
- repo: https://github.com/astral-sh/ruff-pre-commit
2316
rev: v0.2.2
2417
hooks:

pyproject.toml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,35 @@ testing = [
4646
Homepage = "https://execnet.readthedocs.io/en/latest/"
4747

4848
[tool.ruff.lint]
49-
ignore = ["E741"]
50-
extend-select = ["I001"]
49+
extend-select = [
50+
"B", # bugbear
51+
"E", # pycodestyle
52+
"F", # pyflakes
53+
"I", # isort
54+
"PYI", # flake8-pyi
55+
"UP", # pyupgrade
56+
"RUF", # ruff
57+
"W", # pycodestyle
58+
"PIE", # flake8-pie
59+
"PGH", # pygrep-hooks
60+
"PLE", # pylint error
61+
"PLW", # pylint warning
62+
]
63+
ignore = [
64+
# bugbear ignore
65+
"B007", # Loop control variable `i` not used within loop body
66+
"B011", # Do not `assert False` (`python -O` removes these calls)
67+
# pycodestyle ignore
68+
"E501", # Line too long
69+
"E741", # Ambiguous variable name
70+
# ruff ignore
71+
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
72+
# pylint ignore
73+
"PLW0603", # Using the global statement
74+
"PLW0120", # remove the else and dedent its contents
75+
"PLW2901", # for loop variable overwritten by assignment target
76+
"PLR5501", # Use `elif` instead of `else` then `if`
77+
]
5178

5279
[tool.ruff.lint.isort]
5380
force-single-line = true

src/execnet/gateway.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def __init__(self, kwargs):
143143
self.__dict__.update(kwargs)
144144

145145
def __repr__(self):
146-
info = ", ".join("%s=%s" % item for item in sorted(self.__dict__.items()))
146+
info = ", ".join(f"{k}={v}" for k, v in sorted(self.__dict__.items()))
147147
return "<RInfo %r>" % info
148148

149149

src/execnet/gateway_base.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,7 @@ def received(self, gateway):
542542

543543
def __repr__(self):
544544
name = self._types[self.msgcode][0]
545-
return "<Message {} channel={} lendata={}>".format(
546-
name, self.channelid, len(self.data)
547-
)
545+
return f"<Message {name} channel={self.channelid} lendata={len(self.data)}>"
548546

549547
def _status(message, gateway):
550548
# we use the channelid to send back information
@@ -1316,7 +1314,7 @@ def load(self, versioned=False):
13161314
loader = self.num2func[opcode]
13171315
except KeyError:
13181316
raise LoadError(
1319-
"unknown opcode %r - wire protocol corruption?" % (opcode,)
1317+
f"unknown opcode {opcode!r} - wire protocol corruption?"
13201318
) from None
13211319
loader(self)
13221320
except _Stop:
@@ -1593,7 +1591,7 @@ def _save_integral(self, i, short_op, long_op):
15931591
def save_int(self, i):
15941592
self._save_integral(i, opcode.INT, opcode.LONGINT)
15951593

1596-
def save_long(self, l): # noqa:E741
1594+
def save_long(self, l):
15971595
self._save_integral(l, opcode.LONG, opcode.LONGLONG)
15981596

15991597
def save_float(self, flt):

src/execnet/rsync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class RSync:
2424
def __init__(self, sourcedir, callback=None, verbose=True):
2525
self._sourcedir = str(sourcedir)
2626
self._verbose = verbose
27-
assert callback is None or hasattr(callback, "__call__")
27+
assert callback is None or callable(callback)
2828
self._callback = callback
2929
self._channels = {}
3030
self._receivequeue = Queue()
@@ -168,7 +168,7 @@ def _send_directory(self, path):
168168
names.append(name)
169169
subpaths.append(p)
170170
mode = os.lstat(path).st_mode
171-
self._broadcast([mode] + names)
171+
self._broadcast([mode, *names])
172172
for p in subpaths:
173173
self._send_directory_structure(p)
174174

src/execnet/rsync_remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def receive_directory_structure(path, relcomponents):
4242
entrynames = {}
4343
for entryname in msg:
4444
destpath = os.path.join(path, entryname)
45-
receive_directory_structure(destpath, relcomponents + [entryname])
45+
receive_directory_structure(destpath, [*relcomponents, entryname])
4646
entrynames[entryname] = True
4747
if options.get("delete"):
4848
for othername in os.listdir(path):

src/execnet/script/shell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def run(self):
5555

5656
while 1:
5757
try:
58-
clientfile.write("%s %s >>> " % loc)
58+
clientfile.write("{} {} >>> ".format(*loc))
5959
clientfile.flush()
6060
line = filein.readline()
6161
if not line:

src/execnet/script/socketserver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def print_(*args):
4848
def exec_from_one_connection(serversock):
4949
print_(progname, "Entering Accept loop", serversock.getsockname())
5050
clientsock, address = serversock.accept()
51-
print_(progname, "got new connection from %s %s" % address)
51+
print_(progname, "got new connection from {} {}".format(*address))
5252
clientfile = clientsock.makefile("rb")
5353
print_("reading line")
5454
# rstrip so that we can use \r\n for telnet testing
@@ -60,7 +60,7 @@ def exec_from_one_connection(serversock):
6060
co = compile(source + "\n", "<socket server>", "exec")
6161
print_(progname, "compiled source, executing")
6262
try:
63-
exec_(co, g) # noqa
63+
exec_(co, g) # noqa: F821
6464
finally:
6565
print_(progname, "finished executing code")
6666
# background thread might hold a reference to this (!?)

testing/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ def gw(request, execmodel, group):
152152
proxygw = group.makegateway("popen//id=%s" % pname)
153153
# assert group['proxygw'].remote_status().receiving
154154
gw = group.makegateway(
155-
"socket//id=socket//installvia=%s"
156-
"//execmodel=%s" % (pname, execmodel.backend)
155+
f"socket//id=socket//installvia={pname}"
156+
f"//execmodel={execmodel.backend}"
157157
)
158158
gw.proxygw = proxygw
159159
assert pname in group

testing/test_basics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# ruff: noqa: B018
12
from __future__ import annotations
23

34
import inspect

0 commit comments

Comments
 (0)