Skip to content

Commit 1923638

Browse files
committed
fix types
1 parent 6b4c430 commit 1923638

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

cwltool/singularity.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ def _singularity_supports_userns(): # type: ()->bool
5555
return _USERNS
5656

5757

58-
def get_version():
58+
def get_version(): # type: ()->Text
5959
global _SINGULARITY_VERSION # pylint: disable=global-statement
6060
if not _SINGULARITY_VERSION:
61-
_SINGULARITY_VERSION = check_output(["singularity", "--version"], text=True)
61+
_SINGULARITY_VERSION = check_output(["singularity", "--version"], universal_newlines=True)
6262
if _SINGULARITY_VERSION.startswith("singularity version "):
6363
_SINGULARITY_VERSION = _SINGULARITY_VERSION[20:]
6464
return _SINGULARITY_VERSION
6565

66-
def is_version_2_6():
66+
def is_version_2_6(): # type: ()->bool
6767
return get_version().startswith("2.6")
6868

69-
def is_version_3_or_newer():
69+
def is_version_3_or_newer(): # type: ()->bool
7070
return int(get_version()[0]) >= 3
7171

72-
def is_version_3_1_or_newer(): # OCI compatible ??
72+
def is_version_3_1_or_newer(): # type: ()->bool
7373
version = get_version().split('.')
7474
return int(version[0]) >= 4 or (int(version[0]) == 3 and int(version[1]) >= 1)
7575

@@ -179,7 +179,7 @@ def get_image(dockerRequirement, # type: Dict[Text, Text]
179179
name = "{}.sif".format(dockerRequirement["dockerImageId"])
180180
else:
181181
name = "{}.sif".format(dockerRequirement["dockerLoad"])
182-
cmd ["singularity", "build", name,
182+
cmd = ["singularity", "build", name,
183183
"docker-archive://{}".format(dockerRequirement["dockerLoad"])]
184184
_logger.info(Text(cmd))
185185
check_call(cmd, stdout=sys.stderr) # nosec

tests/test_singularity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_singularity_local(tmp_path):
6666
['--singularity', get_data("tests/sing_pullfolder_test.cwl"), "--message", "hello"])
6767
assert result_code == 0
6868

69-
@needs_singularity
69+
@needs_singularity_2_6
7070
def test_singularity_docker_image_id_in_tool(tmp_path):
7171
workdir = tmp_path / "working_dir"
7272
workdir.mkdir()

tests/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ def get_data(filename):
6060
reason="Requires the singularity executable on the system path.")
6161

6262
needs_singularity_2_6 = pytest.mark.skipif(
63-
not is_version_2_6(),
63+
not (distutils.spawn.find_executable('singularity') and is_version_2_6()),
6464
reason="Requires that version 2.6.x of singularity executable version is on the system path.")
6565

6666
needs_singularity_3_or_newer = pytest.mark.skipif(
67-
not is_version_3_or_newer,
67+
not (distutils.spawn.find_executable('singularity') and is_version_3_or_newer),
6868
reason="Requires that version 2.6.x of singularity executable version is on the system path.")
6969

7070

0 commit comments

Comments
 (0)