Skip to content

Commit 43939a0

Browse files
apply pyupgrade + update pre-commit
1 parent 54770eb commit 43939a0

25 files changed

+131
-147
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
exclude: doc/en/example/py2py3/test_py2.py
22
repos:
33
- repo: https://github.com/psf/black
4-
rev: 22.3.0
4+
rev: 22.12.0
55
hooks:
66
- id: black
7-
args: [--safe, --quiet]
87
- repo: https://github.com/asottile/blacken-docs
98
rev: v1.12.1
109
hooks:
1110
- id: blacken-docs
12-
additional_dependencies: [black==19.3b0]
11+
additional_dependencies: [black==22.12.0]
1312
- repo: https://github.com/pre-commit/pre-commit-hooks
14-
rev: v4.2.0
13+
rev: v4.4.0
1514
hooks:
1615
- id: trailing-whitespace
1716
- id: end-of-file-fixer
1817
- id: check-yaml
18+
- repo: https://github.com/asottile/pyupgrade
19+
rev: v3.3.1
20+
hooks:
21+
- id: pyupgrade
22+
args: [--py37-plus]
1923
- repo: https://github.com/asottile/reorder_python_imports
20-
rev: v3.1.0
24+
rev: v3.9.0
2125
hooks:
2226
- id: reorder-python-imports
23-
args: ['--application-directories=execnet']
27+
args: ['--application-directories=execnet', --py37-plus]
2428
- repo: local
2529
hooks:
2630
- id: rst

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
------------------
33

44
* removed support for Python < 3.7
5+
* apply pyupgrade --py37-plus
56
* migrate packaging to hatch
67

8+
79
1.9.0 (2021-06-13)
810
------------------
911

doc/example/popen_read_multiple.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
44
reading results from possibly blocking code running in sub processes.
55
"""
6-
from __future__ import print_function
7-
86
import execnet
97

108
NUM_PROCESSES = 5

doc/example/redirect_remote_output.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
- setting a callback for receiving channel data
88
99
"""
10-
from __future__ import print_function
11-
1210
import execnet
1311

1412
gw = execnet.makegateway()

doc/example/svn-sync-repo.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
uses execnet.
66
77
"""
8-
from __future__ import print_function
9-
108
import os
119
import sys
1210

@@ -23,7 +21,7 @@ def main(args):
2321
remote = args[0]
2422
localrepo = py.path.local(args[1])
2523
if not localrepo.check(dir=1):
26-
raise SystemExit("localrepo {} does not exist".format(localrepo))
24+
raise SystemExit(f"localrepo {localrepo} does not exist")
2725
if len(args) == 3:
2826
configfile = args[2]
2927
else:
@@ -95,7 +93,7 @@ def svn_load(repo, dumpchannel, maxcount=100):
9593
# growing buffers (execnet does not control
9694
# RAM usage or receive queue sizes)
9795
dumpchannel.send(maxcount)
98-
f = os.popen("svnadmin load -q {}".format(repo), "w")
96+
f = os.popen(f"svnadmin load -q {repo}", "w")
9997
count = maxcount
10098
for x in dumpchannel:
10199
sys.stdout.write(".")

doc/example/sysinfo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,21 @@ def error(*args):
127127

128128
def getinfo(sshname, ssh_config=None, loginfo=sys.stdout):
129129
if ssh_config:
130-
spec = "ssh=-F {} {}".format(ssh_config, sshname)
130+
spec = f"ssh=-F {ssh_config} {sshname}"
131131
else:
132132
spec += "ssh=%s" % sshname
133133
debug("connecting to", repr(spec))
134134
try:
135135
gw = execnet.makegateway(spec)
136-
except IOError:
136+
except OSError:
137137
error("could not get sshgatway", sshname)
138138
else:
139139
ri = RemoteInfo(gw)
140140
# print "%s info:" % sshname
141141
prefix = sshname.upper() + " "
142142
print >> loginfo, prefix, "fqdn:", ri.getfqdn()
143143
for attr in ("sys.platform", "sys.version_info"):
144-
loginfo.write("{} {}: ".format(prefix, attr))
144+
loginfo.write(f"{prefix} {attr}: ")
145145
loginfo.flush()
146146
value = ri.getmodattr(attr)
147147
loginfo.write(str(value))

doc/example/taskserver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ def process_item(channel):
3636
break
3737
continue
3838
if item != "ready":
39-
print("other side {} returned {!r}".format(channel.gateway.id, item))
39+
print(f"other side {channel.gateway.id} returned {item!r}")
4040
if not tasks:
4141
print("no tasks remain, sending termination request to all")
4242
mch.send_each(None)
4343
tasks = -1
4444
if tasks and tasks != -1:
4545
task = tasks.pop()
4646
channel.send(task)
47-
print("sent task {!r} to {}".format(task, channel.gateway.id))
47+
print(f"sent task {task!r} to {channel.gateway.id}")
4848

4949
group.terminate()

execnet/deprecated.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def SocketGateway(host, port):
2525
new_remote() method on existing gateways.
2626
"""
2727
APIWARN("1.0.0b4", "use makegateway('socket=host:port')")
28-
spec = execnet.XSpec("socket={}:{}".format(host, port))
28+
spec = execnet.XSpec(f"socket={host}:{port}")
2929
return execnet.default_group.makegateway(spec)
3030

3131

@@ -44,5 +44,5 @@ def SshGateway(sshaddress, remotepython=None, ssh_config=None):
4444
def APIWARN(version, msg, stacklevel=3):
4545
import warnings
4646

47-
Warn = DeprecationWarning("(since version {}) {}".format(version, msg))
47+
Warn = DeprecationWarning(f"(since version {version}) {msg}")
4848
warnings.warn(Warn, stacklevel=stacklevel)

execnet/gateway.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Gateway(gateway_base.BaseGateway):
2121
"""Gateway to a local or remote Python Intepreter."""
2222

2323
def __init__(self, io, spec):
24-
super(Gateway, self).__init__(io=io, id=spec.id, _startcount=1)
24+
super().__init__(io=io, id=spec.id, _startcount=1)
2525
self.spec = spec
2626
self._initreceive()
2727

@@ -56,7 +56,7 @@ def exit(self):
5656
self._send(Message.GATEWAY_TERMINATE)
5757
self._trace("--> io.close_write")
5858
self._io.close_write()
59-
except (ValueError, EOFError, IOError):
59+
except (ValueError, EOFError, OSError):
6060
v = sys.exc_info()[1]
6161
self._trace("io-error: could not send termination sequence")
6262
self._trace(" exception: %r" % v)
@@ -211,7 +211,7 @@ def _source_of_function(function):
211211

212212
try:
213213
source = inspect.getsource(function)
214-
except IOError:
214+
except OSError:
215215
raise ValueError("can't find source file for %s" % function)
216216

217217
source = textwrap.dedent(source) # just for inner functions

0 commit comments

Comments
 (0)