Repository navigation
Fix apostrophes in dropdown names breaking generated revision files - #287
Open
JeetuSK0808 wants to merge 1 commit into
Open
JeetuSK0808 wants to merge 1 commit into
JeetuSK0808 wants to merge 1 commit into
Conversation
BaseOperation.__repr__ wrapped string arguments in single quotes with no escaping, so a dropdown name or option like 5' UTR was written into the revision file as '5' UTR', which isn't valid Python, and Revision.parse_from_file failed the next time the timeline loaded. Use repr() for string arguments instead. For strings without a quote or backslash the output is byte for byte the same, so existing revision files don't change. Adds tests that round-trip operations with apostrophes and double quotes, and a whole revision file written and parsed back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What was wrong
BaseOperation.__repr__wraps string arguments in single quotes with no escaping (liminal/base/base_operation.py, line 78), and that's whatrevision_file_string()writes into autogenerated revision files. So a dropdown name or option with an apostrophe, like5' UTRon a Primer End dropdown, is written as:which isn't valid Python, and
Revision.parse_from_filefails on it the next time the timeline loads. #265 fixed the same kind of thing in the generated dropdown model files, but revision files go through this separate path.Fix
Use
repr(str(v))for string arguments (1 line). It quotes and escapes, so the line above becomesb.CreateDropdownOption('Primer End', "5' UTR", 0). For strings without a quote or backslash the output is byte for byte the same as before, so existing revision files don't change.Tests
New
liminal/tests/test_revision_file_quotes.py:test_revision_file_string_round_trips_quotes: 3 operations with apostrophes and a double quote, each evaluated back fromrevision_file_string()and compared with the original.test_revision_file_with_apostrophes_parses_back: writes a whole revision file withwrite_revision_fileand reads it back withRevision.parse_from_file.Results (run locally, macOS arm64, Python 3.12)
mainwithout the fix: all 4 fail.pytest liminalgives 44 passed (the 40 existing plus the 4 new).ruff check,ruff format --checkandmypy --sqlite-cacheare clean.main, and none with the fix.🤖 Generated with Claude Code