Add __repr__ to Region and CacheMiss utility classes (fixes #1219)#1220
Merged
jonbrenas merged 3 commits intomalariagen:masterfrom Mar 24, 2026
Merged
Conversation
…riagen#1219) - Region.__repr__ returns a constructor-style string, e.g. Region('2L', 100000, 200000) so that Region objects display usefully inside lists, dicts, and REPL sessions, complementing the existing __str__ (e.g. '2L:100,000-200,000'). - CacheMiss gains a default message and __repr__: - CacheMiss() → str 'Cache miss: requested item not found in cache.' - CacheMiss('key') → str "Cache miss for key: 'key'" - repr(CacheMiss('k')) → "CacheMiss('k')" - Added tests/test_util.py covering both classes.
Contributor
Author
|
hey @jonbrenas , |
jonbrenas
approved these changes
Mar 24, 2026
Contributor
Author
|
hey @jonbrenas , |
Contributor
Author
|
Hi @jonbrenas , |
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.
Summary
Fixes #1219.
The
Regionclass had a useful__str__but no__repr__, meaning it displayed as an unhelpful<malariagen_data.util.Region object at 0x...>inside lists, dicts, and REPL sessions. SimilarlyCacheMisswas a bareExceptionsubclass with no message formatting.Changes
malariagen_data/util.pyRegion.__repr__— returns a constructor-style string:(the existing
__str__format is unchanged:'2L:100,000-200,000')CacheMiss— adds a docstring, default message, and__repr__:tests/test_util.py(new file)Unit tests covering all the above behaviours.
Testing
All existing tests continue to pass. New tests added in
tests/test_util.py.