Commit 3ad81ba
committed
snapshot.py(refactor[performance]): Extract helper function for session snapshot creation
why: Address PERF203 linting warning about try-except blocks within loops, which can cause performance overhead.
what:
- Created _create_session_snapshot_safely helper function to isolate exception handling
- Refactored ServerSnapshot.from_server to use the helper function instead of inline try-except
- Added comprehensive docstrings explaining the purpose and implementation
- Maintained the same behavior for both test and production environments
- Improved code readability and maintainability
This approach resolves the linting warning while preserving the intended behavior
and special handling for test environments.1 parent e4aec76 commit 3ad81ba
1 file changed
+54
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
673 | 673 | | |
674 | 674 | | |
675 | 675 | | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | | - | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
682 | 680 | | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | 681 | | |
696 | 682 | | |
697 | 683 | | |
| |||
704 | 690 | | |
705 | 691 | | |
706 | 692 | | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
707 | 743 | | |
708 | 744 | | |
709 | 745 | | |
| |||
0 commit comments