Whole file
jongracecox/anybadge
The author described this change as “Fix int and float value detection (#26)”. It counts as a record because the check below fails on the code as it stood at 6465c451c and passes on aebea0934, with nothing else changed between the two runs.
Projectjongracecox/anybadge
Fix saved2019-07-12
Sharing licenceMIT · LICENSE
Change size+8 −1
What the code was meant to do, written into the code itself as a save note
Fix int and float value detection (#26)
The change
| 280 | 280 | ||
| 281 | 281 | Returns: bool | |
| 282 | 282 | """ | |
| 283 | + | ||
| 284 | + | # If the value is an int then it should not be considered a float. | |
| 285 | + | # We need to check this first before we check whether it is a float because the | |
| 286 | + | # float check also returns True for an int string. | |
| 287 | + | if self.value_is_int: | |
| 288 | + | return False | |
| 289 | + | ||
| 283 | 290 | try: | |
| 284 | 291 | _ = float(self.value) | |
| 285 | 292 | except ValueError: | |
| ⋯ | |||
| 395 | 402 | ||
| 396 | 403 | >>> badge = Badge('pylint', '5') | |
| 397 | 404 | >>> badge.badge_width | |
| 398 | - | 65 | |
| 405 | + | 53 | |
| 399 | 406 | """ | |
| 400 | 407 | padding_char_width = self.get_text_width(' ') | |
| 401 | 408 | padding = int(padding_char_width * (self.num_padding_chars + 3)) | |
The check that tells the two apart
fail→pass·tests/test_anybadge.py::TestAnybadge::test_integer_value_is_handled_as_integer
Check file tests/test_anybadge.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 it6465c451c4af18cbb732f0e051dcb9734febdb5d
Broken version dated2019-07-12
Moduleanybadge
Units changedBadge
Fingerprint9cd4adca9625ae43
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.