Skip to content

Commit 18c3d3d

Browse files
committed
fix: parse parameter strings containing '=' in papermill/translators.py
Change the threshold for skipping lines with multiple equals signs from nequal > 1 to nequal > 2. Lines like s = 'a=b' have 2 equals signs (one assignment, one inside the string), but were incorrectly skipped as unparseable multi-assignments. Fixes issue #864: Parameter strings cannot contain '=' - Before: s = 'a=b' was skipped (nequal=2, threshold was >1) - After: s = 'a=b' is correctly parsed (nequal=2, threshold is now >2) - Multi-assignment lines like a = b = 1 (nequal=3) are still skipped Also adds a test case for parameter strings with embedded equals.
1 parent e4e4ddd commit 18c3d3d

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

papermill/tests/test_translators.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ def test_translate_comment_python(test_input, expected):
107107
Parameter("b", "float", "-2.3432", "My b variable"),
108108
],
109109
),
110+
(
111+
's = "a=b"',
112+
[Parameter("s", "None", '"a=b"', "")],
113+
),
110114
],
111115
)
112116
def test_inspect_python(test_input, expected):

papermill/translators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def flatten_accumulator(accumulator):
246246
if nequal > 0:
247247
grouped_variable.append(flatten_accumulator(accumulator))
248248
accumulator = []
249-
if nequal > 1:
249+
if nequal > 2:
250250
logger.warning(f"Unable to parse line {iline + 1} '{line}'.")
251251
continue
252252

0 commit comments

Comments
 (0)