Commit 48578f5
committed
fix(asc): address PR review feedback on timestamps_format
Reviewer feedback received (zariiii9003):
1. Use Literal type hint for timestamps_format parameter
- Changed: timestamps_format: str = "absolute"
- To: timestamps_format: Literal["absolute", "relative"] = "absolute"
- Added Literal to typing imports
2. Simplify log_event timestamp computation
- Moved monotonic clamp out of if/else blocks:
timestamp = max(timestamp, self.last_timestamp)
- Each branch now contains only simple arithmetic:
absolute: written_timestamp = timestamp - self.started
relative: written_timestamp = timestamp - self.last_timestamp
3. Use relative_timestamp=False in roundtrip tests
- Updated test_write_relative_timestamp_roundtrip and
test_write_absolute_timestamps_are_offsets_from_start to use
relative_timestamp=False so assertions verify original message
timestamps are recovered (100.0, 100.3, 101.0) rather than
file-stored offsets (0.0, 0.3, 1.0)
Additional issues found and fixed during review:
4. Removed outdated TODO comment in ASCReader
- Removed: "TODO - what is this used for? The ASC Writer only prints
absolute" — no longer accurate since ASCWriter now supports both
"absolute" and "relative" formats
5. Lowered assertAlmostEqual precision from places=5 to places=3
- The datetime triggerblock roundtrip (fromtimestamp -> strftime ->
strptime -> timestamp) only preserves millisecond precision due to
the ".NNN" format. places=5 (5 microseconds) is stricter than what
the format can guarantee; places=3 (0.5 ms) correctly reflects the
actual precision limit. Verified empirically: sub-millisecond
timestamps incur ~0.456 ms error which passes places=3 but fails
places=5.
6. Updated docstrings for both modified roundtrip tests to accurately
describe the new assertion semantics (original timestamp recovery)1 parent a48e2fd commit 48578f5
2 files changed
Lines changed: 14 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | 78 | | |
80 | 79 | | |
81 | 80 | | |
| |||
462 | 461 | | |
463 | 462 | | |
464 | 463 | | |
| 464 | + | |
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
468 | | - | |
469 | | - | |
470 | | - | |
| 468 | + | |
471 | 469 | | |
472 | 470 | | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
| 471 | + | |
478 | 472 | | |
479 | 473 | | |
480 | 474 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
711 | 711 | | |
712 | 712 | | |
713 | 713 | | |
714 | | - | |
| 714 | + | |
715 | 715 | | |
716 | 716 | | |
717 | 717 | | |
| |||
721 | 721 | | |
722 | 722 | | |
723 | 723 | | |
724 | | - | |
| 724 | + | |
725 | 725 | | |
726 | 726 | | |
727 | 727 | | |
728 | | - | |
729 | | - | |
730 | | - | |
| 728 | + | |
| 729 | + | |
731 | 730 | | |
732 | 731 | | |
733 | 732 | | |
| |||
754 | 753 | | |
755 | 754 | | |
756 | 755 | | |
757 | | - | |
758 | | - | |
| 756 | + | |
| 757 | + | |
759 | 758 | | |
760 | 759 | | |
761 | 760 | | |
| |||
766 | 765 | | |
767 | 766 | | |
768 | 767 | | |
769 | | - | |
| 768 | + | |
770 | 769 | | |
771 | 770 | | |
772 | 771 | | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
777 | 776 | | |
778 | 777 | | |
779 | 778 | | |
| |||
0 commit comments