Repository navigation
Commit 59b3cb2
committed
refactor(widgets): dedup ETA value/elapsed + make UnknownLength explicit
ETA.__call__ and SmoothingETA.__call__ shared an identical value/elapsed
default-resolution preamble. Extract it into ETA._resolve_value_elapsed()
and call it from both; the shared helper's branches are covered by the ETA
paths so SmoothingETA no longer needs its two '# pragma: no branch'.
Also replace the TypeError-as-control-flow around _calculate_eta with an
explicit 'progress.max_value is base.UnknownLength' check. The only source
of that TypeError was subtracting the value from the UnknownLength sentinel
inside _calculate_eta's 'if elapsed:' branch, so the explicit check is
guarded by 'elapsed' too: this keeps the elapsed==0 case returning 0
(format_zero) instead of N/A, preserving byte-identical output. Nothing
else in the ETA math raises TypeError, so the try/except is removed
entirely rather than kept as a defensive handler.
Behavior-preserving: full suite + render goldens unchanged, widgets.py at
100% branch coverage.1 parent 3aaf461 commit 59b3cb2
1 file changed
Lines changed: 36 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
569 | 569 | | |
570 | 570 | | |
571 | 571 | | |
572 | | - | |
| 572 | + | |
573 | 573 | | |
574 | 574 | | |
575 | 575 | | |
576 | | - | |
577 | | - | |
| 576 | + | |
| 577 | + | |
578 | 578 | | |
579 | | - | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
580 | 585 | | |
581 | | - | |
582 | | - | |
583 | 586 | | |
584 | 587 | | |
585 | 588 | | |
586 | 589 | | |
587 | 590 | | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
588 | 611 | | |
589 | | - | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
590 | 616 | | |
591 | 617 | | |
592 | 618 | | |
593 | 619 | | |
594 | 620 | | |
595 | 621 | | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | 622 | | |
600 | 623 | | |
601 | 624 | | |
| |||
722 | 745 | | |
723 | 746 | | |
724 | 747 | | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
733 | 751 | | |
734 | 752 | | |
735 | 753 | | |
| |||
0 commit comments