Skip to content

Fix parameter parsing when value contains '=' inside a string (#864)#880

Open
SAY-5 wants to merge 2 commits into
nteract:mainfrom
SAY-5:fix/parameter-strings-with-equals
Open

Fix parameter parsing when value contains '=' inside a string (#864)#880
SAY-5 wants to merge 2 commits into
nteract:mainfrom
SAY-5:fix/parameter-strings-with-equals

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 12, 2026

Fixes #864.

PythonTranslator.inspect counted = characters naively with line.count("="), so lines like s = "a=b" were flagged as having multiple assignments and skipped with an Unable to parse warning. The cell ended up exposing no s parameter, and any value passed to it via papermill -p s ... was then reported as Passed unknown parameter: s.

Replaced the naive count with a small helper that tokenizes the line via the tokenize module and counts only top-level OP tokens with string =. = inside string literals is not an OP token, so it is no longer counted. Falls back to the original naive count on TokenError / SyntaxError so partial multiline definitions still flow into the existing accumulator path unchanged.

The existing PARAMETER_PATTERN regex already handles values containing = correctly; the fix is purely the pre-filter that was rejecting them too early.

Added two parametrize entries to test_inspect_python as regression tests for = in double- and single-quoted string literals. Full papermill/tests/test_translators.py suite (277 tests) passes locally.

SAY-5 and others added 2 commits May 11, 2026 22:16
PythonTranslator.inspect treated any line with more than one '=' as
unparseable, which incorrectly rejected parameter lines like
s = "a=b" where the second '=' is inside a string literal.

Count only top-level assignment operators using tokenize so the
existing PARAMETER_PATTERN regex (which already handles '=' in values
correctly) is given a chance to match.

Closes nteract#864
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