Whole file
careless25/text2digits
The author described this change as “Raise valueError if value/scale didnt match”. It counts as a record because the checks below fail on the code as it stood at 4cfa43d58 and pass on 56b6b8b86, with nothing else changed between the two runs.
Projectcareless25/text2digits
Fix saved2026-04-28
Sharing licenceMIT · LICENSE
Change size+2 −0
What the code was meant to do, written into the code itself as a save note
Raise valueError if value/scale didnt match
The change
| 115 | 115 | return Decimal(self._word) | |
| 116 | 116 | elif self.type != WordType.OTHER: | |
| 117 | 117 | return Decimal(Token.numwords[self._word][1]) | |
| 118 | + | raise ValueError(f"Cannot compute value for token of type {self.type!r} (word={self.word_raw!r})") | |
| 118 | 119 | ||
| 119 | 120 | def scale(self) -> Decimal: | |
| 120 | 121 | """ | |
| ⋯ | |||
| 127 | 128 | return Decimal(1) | |
| 128 | 129 | elif self.type != WordType.OTHER: | |
| 129 | 130 | return Decimal(Token.numwords[self._word][0]) | |
| 131 | + | raise ValueError(f"Cannot compute scale for token of type {self.type!r} (word={self.word_raw!r})") | |
| 130 | 132 | ||
| 131 | 133 | def text(self) -> str: | |
| 132 | 134 | """ | |
The check that tells the two apart
fail→pass·tests/test_tokens.py::TestOtherTokenValueScale::test_error_message_includes_word
fail→pass·tests/test_tokens.py::TestOtherTokenValueScale::test_scale_raises_for_other
fail→pass·tests/test_tokens.py::TestOtherTokenValueScale::test_value_raises_for_other
Check file tests/test_tokens.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it4cfa43d589ebe3377a3112b633006614c15e7f94
Broken version dated2026-04-28
Moduletext2digits.tokens_basic
Units changedToken
Fingerprint39862d57600e13bc
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in careless25/text2digits
- 2026-04-28Fix how 'oh' is handled
- 2026-04-28find_similar_word
- 2026-04-28bigram_similarity
- 2026-04-24split_glues
- 2020-04-29Fix handling of time formats, add tests (from PR #27)