Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
Overhang.IO committed Sep 6, 2023
2 parents 6941021 + 51928b0 commit d58df5c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [Bugfix] Correctly parse strings prefixed with pound "#" key in `tutor config save --set KEY=#value` commands. (by @regisb)
4 changes: 4 additions & 0 deletions tests/test_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def test_parse_key_value(self) -> None:
"x=key1:\n subkey: value\nkey2:\n subkey: value"
),
)
self.assertEqual(
("INDIGO_PRIMARY_COLOR", "#225522"),
serialize.parse_key_value("INDIGO_PRIMARY_COLOR=#225522"),
)

def test_str_format(self) -> None:
self.assertEqual("true", serialize.str_format(True))
Expand Down
4 changes: 4 additions & 0 deletions tutor/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,8 @@ def parse_key_value(text: str) -> t.Optional[tuple[str, t.Any]]:
if not value:
# Empty strings are interpreted as null values, which is incorrect.
value = "''"
elif "\n" not in value and value.startswith("#"):
# Single-line string that starts with a pound # key
# We need to escape the string, otherwise pound will be interpreted as a comment.
value = f'"{value}"'
return key, parse(value)

0 comments on commit d58df5c

Please sign in to comment.