Skip to content

Commit 04e2fa4

Browse files
scuba: Fix make_vol_opt trailing colon bug
When make_vol_opt() was called with options=[], it would return a volume spec which erroneously contained a trailing colon. Also, this removes the unnecessary flexibility of passing a single option string (as opposed to a sequence of option strings). This wasn't intended by the type signature for options, but unforunately a 'str' is a 'Sequence[str]'. See python/mypy#11001. This fixes #215.
1 parent c6f3e62 commit 04e2fa4

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

‎scuba/dockerutil.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ def make_vol_opt(
137137
) -> str:
138138
"""Generate a docker volume option"""
139139
vol = f"--volume={hostdir}:{contdir}"
140-
if options is not None:
141-
if isinstance(options, str):
142-
options = (options,)
140+
if options:
141+
assert not isinstance(options, str)
143142
vol += ":" + ",".join(options)
144143
return vol

‎tests/test_dockerutil.py‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,8 @@ def test_make_vol_opt_no_opts():
108108
assert uut.make_vol_opt("/hostdir", "/contdir") == "--volume=/hostdir:/contdir"
109109

110110

111-
def test_make_vol_opt_one_opt():
112-
assert (
113-
uut.make_vol_opt("/hostdir", "/contdir", "ro")
114-
== "--volume=/hostdir:/contdir:ro"
115-
)
111+
def test_make_vol_opt_empty_opts():
112+
assert uut.make_vol_opt("/hostdir", "/contdir", []) == "--volume=/hostdir:/contdir"
116113

117114

118115
def test_make_vol_opt_multi_opts():

0 commit comments

Comments
 (0)