Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions papermill/tests/test_translators.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def test_translate_comment_python(test_input, expected):
"a: List[str] = ['this', 'is', 'a', 'string', 'list'] # Nice variable a",
[Parameter("a", "List[str]", "['this', 'is', 'a', 'string', 'list']", "Nice variable a")],
),
(
"a: datetime.date = '2024-01-01' # Nice variable a",
[Parameter("a", "datetime.date", "'2024-01-01'", "Nice variable a")],
),
(
"a: List[str] = [\n 'this', # First\n 'is',\n 'a',\n 'string',\n 'list' # Last\n] # Nice variable a", # noqa
[Parameter("a", "List[str]", "['this','is','a','string','list']", "Nice variable a")],
Expand Down
2 changes: 1 addition & 1 deletion papermill/translators.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def inspect(cls, parameters_cell):
class PythonTranslator(Translator):
# Pattern to capture parameters within cell input
PARAMETER_PATTERN = re.compile(
r"^(?P<target>\w[\w_]*)\s*(:\s*[\"']?(?P<annotation>\w[\w_\[\],\s]*)[\"']?\s*)?=\s*(?P<value>.*?)(\s*#\s*(type:\s*(?P<type_comment>[^\s]*)\s*)?(?P<help>.*))?$"
r"^(?P<target>\w[\w_]*)\s*(:\s*[\"']?(?P<annotation>\w[\w_\[\],\s\.]*)[\"']?\s*)?=\s*(?P<value>.*?)(\s*#\s*(type:\s*(?P<type_comment>[^\s]*)\s*)?(?P<help>.*))?$"
)

@classmethod
Expand Down
Loading