Skip to content

Commit f067a03

Browse files
committed
MNT: pyupgrade --py37-plus
1 parent 64bfa89 commit f067a03

File tree

7 files changed

+14
-16
lines changed

7 files changed

+14
-16
lines changed

pydra/engine/helpers_state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def _add_name(mlist, name):
344344
if "." in elem or elem.startswith("_"):
345345
pass
346346
else:
347-
mlist[i] = "{}.{}".format(name, mlist[i])
347+
mlist[i] = f"{name}.{mlist[i]}"
348348
elif isinstance(elem, list):
349349
mlist[i] = _add_name(elem, name)
350350
elif isinstance(elem, tuple):

pydra/engine/state.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,11 @@ def _remove_repeated(self, previous_splitters):
454454
f"{self.other_states}"
455455
)
456456

457-
repeated = set(
458-
[
459-
(el, previous_splitters.count(el))
460-
for el in previous_splitters
461-
if previous_splitters.count(el) > 1
462-
]
463-
)
457+
repeated = {
458+
(el, previous_splitters.count(el))
459+
for el in previous_splitters
460+
if previous_splitters.count(el) > 1
461+
}
464462
if repeated:
465463
# assuming that I want to remove from right
466464
previous_splitters.reverse()

pydra/engine/tests/test_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_save(tmpdir):
4747

4848
def test_hash_file(tmpdir):
4949
outdir = Path(tmpdir)
50-
with open(outdir / "test.file", "wt") as fp:
50+
with open(outdir / "test.file", "w") as fp:
5151
fp.write("test")
5252
assert (
5353
helpers_file.hash_file(outdir / "test.file")

pydra/engine/tests/test_specs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def test_input_file_hash_1(tmpdir):
168168
inputs(in_file=outfile).hash
169169
== "1384a1eb11cd94a5b826a82b948313b9237a0956d406ccff59e79ec92b3c935f"
170170
)
171-
with open(outfile, "wt") as fp:
171+
with open(outfile, "w") as fp:
172172
fp.write("test")
173173
fields = [("in_file", File)]
174174
input_spec = SpecInfo(name="Inputs", fields=fields, bases=(BaseSpec,))

pydra/engine/tests/test_task.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ def testfunc(a: int, b: float = 0.1) -> ty.NamedTuple("Output", [("out", float)]
10301030
message_path = tmpdir / funky.checksum / "messages"
10311031

10321032
for file in glob(str(message_path) + "/*.jsonld"):
1033-
with open(file, "r") as f:
1033+
with open(file) as f:
10341034
data = json.load(f)
10351035
if "@type" in data:
10361036
if "AssociatedWith" in data:
@@ -1065,7 +1065,7 @@ def test_audit_shellcommandtask(tmpdir):
10651065
command_content = []
10661066

10671067
for file in glob(str(message_path) + "/*.jsonld"):
1068-
with open(file, "r") as f:
1068+
with open(file) as f:
10691069
data = json.load(f)
10701070

10711071
if "@type" in data:
@@ -1148,7 +1148,7 @@ def test_audit_shellcommandtask_file(tmpdir):
11481148
shelly()
11491149
message_path = tmpdir / shelly.checksum / "messages"
11501150
for file in glob.glob(str(message_path) + "/*.jsonld"):
1151-
with open(file, "r") as x:
1151+
with open(file) as x:
11521152
data = json.load(x)
11531153
if "@type" in data:
11541154
if data["@type"] == "input":
@@ -1184,7 +1184,7 @@ def test_audit_shellcommandtask_version(tmpdir):
11841184
# go through each jsonld file in message_path and check if the label field exists
11851185
version_content = []
11861186
for file in glob.glob(str(message_path) + "/*.jsonld"):
1187-
with open(file, "r") as f:
1187+
with open(file) as f:
11881188
data = json.load(f)
11891189
if "AssociatedWith" in data:
11901190
if version_cmd in data["AssociatedWith"]:

pydra/engine/workers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ async def exec_serial(self, runnable, rerun=False):
143143

144144
async def fetch_finished(self, futures):
145145
await asyncio.gather(*futures)
146-
return set([])
146+
return set()
147147

148148
# async def fetch_finished(self, futures):
149149
# return await asyncio.wait(futures)

pydra/utils/messenger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,5 +196,5 @@ def collect_messages(collected_path, message_path, ld_op="compact"):
196196
pld.jsonld.from_rdf(pld.jsonld.to_rdf(data, {})), data[0]
197197
)
198198
records["@id"] = f"uid:{gen_uuid()}"
199-
with open(collected_path / "messages.jsonld", "wt") as fp:
199+
with open(collected_path / "messages.jsonld", "w") as fp:
200200
json.dump(records, fp, ensure_ascii=False, indent=2, sort_keys=False)

0 commit comments

Comments
 (0)