Skip to content

fix: parse parameter strings containing '='#879

Open
AmSach wants to merge 1 commit into
nteract:mainfrom
AmSach:fix/parameter-strings-with-equals
Open

fix: parse parameter strings containing '='#879
AmSach wants to merge 1 commit into
nteract:mainfrom
AmSach:fix/parameter-strings-with-equals

Conversation

@AmSach
Copy link
Copy Markdown

@AmSach AmSach commented May 11, 2026

Fixed the bug described in issue #864. Here's what was wrong and how I fixed it:

The Bug: In papermill/translators.py, the PythonTranslator.inspect() method counts equals signs (=) on each line to detect multi-assignment lines (which it should skip). However, the threshold was nequal > 1, meaning any line with 2 or more = signs was skipped.

This breaks for parameter values containing =, like s = "a=b" (where the = appears inside the string value). Such lines have exactly 2 = signs but are valid single assignments and should be parsed.

The Fix: Changed the threshold from nequal > 1 to nequal > 2. Now only lines with 3 or more = signs (genuine multi-assignment like a = b = c = 1) are skipped. Lines with 1 or 2 = signs are passed to the regex parser, which correctly extracts the parameter name and value.

Test: Added a test case for s = "a=b" to test_translators.py to prevent regression.

Closes #864

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 nteract#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parameter strings cannot contain "="

1 participant