fix: parse parameter strings containing '='#879
Open
AmSach wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed the bug described in issue #864. Here's what was wrong and how I fixed it:
The Bug: In
papermill/translators.py, thePythonTranslator.inspect()method counts equals signs (=) on each line to detect multi-assignment lines (which it should skip). However, the threshold wasnequal > 1, meaning any line with 2 or more=signs was skipped.This breaks for parameter values containing
=, likes = "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 > 1tonequal > 2. Now only lines with 3 or more=signs (genuine multi-assignment likea = 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"totest_translators.pyto prevent regression.Closes #864