Skip to content

Commit 88019c8

Browse files
authored
Remove deprecated use of Pathlib.Path as a context-mananger (#1854)
1 parent dbe5330 commit 88019c8

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

cwltool/main.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,12 +645,9 @@ def setup_schema(
645645
if custom_schema_callback is not None:
646646
custom_schema_callback()
647647
elif args.enable_ext:
648-
with files("cwltool").joinpath("extensions.yml") as res:
649-
ext10 = res.read_text("utf-8")
650-
with files("cwltool").joinpath("extensions-v1.1.yml") as res:
651-
ext11 = res.read_text("utf-8")
652-
with files("cwltool").joinpath("extensions-v1.2.yml") as res:
653-
ext12 = res.read_text("utf-8")
648+
ext10 = files("cwltool").joinpath("extensions.yml").read_text("utf-8")
649+
ext11 = files("cwltool").joinpath("extensions-v1.1.yml").read_text("utf-8")
650+
ext12 = files("cwltool").joinpath("extensions-v1.2.yml").read_text("utf-8")
654651
use_custom_schema("v1.0", "http://commonwl.org/cwltool", ext10)
655652
use_custom_schema("v1.1", "http://commonwl.org/cwltool", ext11)
656653
use_custom_schema("v1.2", "http://commonwl.org/cwltool", ext12)

cwltool/process.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,19 @@ def get_schema(
194194
version = ".".join(version.split(".")[:-1])
195195
for f in cwl_files:
196196
try:
197-
with files("cwltool").joinpath(f"schemas/{version}/{f}") as res:
198-
cache["https://w3id.org/cwl/" + f] = res.read_text("UTF-8")
197+
res = files("cwltool").joinpath(f"schemas/{version}/{f}")
198+
cache["https://w3id.org/cwl/" + f] = res.read_text("UTF-8")
199199
except OSError:
200200
pass
201201

202202
for f in salad_files:
203203
try:
204-
with files("cwltool").joinpath(
204+
res = files("cwltool").joinpath(
205205
f"schemas/{version}/salad/schema_salad/metaschema/{f}",
206-
) as res:
207-
cache["https://w3id.org/cwl/salad/schema_salad/metaschema/" + f] = res.read_text(
208-
"UTF-8"
209-
)
206+
)
207+
cache["https://w3id.org/cwl/salad/schema_salad/metaschema/" + f] = res.read_text(
208+
"UTF-8"
209+
)
210210
except OSError:
211211
pass
212212

cwltool/validate_js.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,16 @@ def jshint_js(
150150
"esversion": 5,
151151
}
152152

153-
with files("cwltool").joinpath("jshint/jshint.js") as res:
154-
# NOTE: we need a global variable for lodash (which jshint depends on)
155-
jshint_functions_text = "var global = this;" + res.read_text("utf-8")
156-
157-
with files("cwltool").joinpath("jshint/jshint_wrapper.js") as res2:
158-
# NOTE: we need to assign to ob, as the expression {validateJS: validateJS} as an expression
159-
# is interpreted as a block with a label `validateJS`
160-
jshint_functions_text += (
161-
"\n" + res2.read_text("utf-8") + "\nvar ob = {validateJS: validateJS}; ob"
162-
)
153+
res = files("cwltool").joinpath("jshint/jshint.js")
154+
# NOTE: we need a global variable for lodash (which jshint depends on)
155+
jshint_functions_text = "var global = this;" + res.read_text("utf-8")
156+
157+
res2 = files("cwltool").joinpath("jshint/jshint_wrapper.js")
158+
# NOTE: we need to assign to ob, as the expression {validateJS: validateJS} as an expression
159+
# is interpreted as a block with a label `validateJS`
160+
jshint_functions_text += (
161+
"\n" + res2.read_text("utf-8") + "\nvar ob = {validateJS: validateJS}; ob"
162+
)
163163

164164
returncode, stdout, stderr = exec_js_process(
165165
"validateJS(%s)" % json_dumps({"code": js_text, "options": options, "globals": globals}),

0 commit comments

Comments
 (0)