| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -611,13 +611,17 @@ def __init__(self) -> None: | |||
| 611 | 611 | self.error_lines: List[str] = [] | |
| 612 | 612 | self.other_lines: List[str] = [] | |
| 613 | 613 | ||
| 614 | - def _parse_progress_line(self, line: AnyStr) -> None: | ||
| 614 | + def _parse_progress_line(self, line: AnyStr) -> Optional[object]: | ||
| 615 | 615 | """Parse progress information from the given line as retrieved by | |
| 616 | 616 | :manpage:`git-push(1)` or :manpage:`git-fetch(1)`. | |
| 617 | 617 | ||
| 618 | 618 | - Lines that do not contain progress info are stored in :attr:`other_lines`. | |
| 619 | 619 | - Lines that seem to contain an error (i.e. start with ``error:`` or ``fatal:``) | |
| 620 | 620 | are stored in :attr:`error_lines`. | |
| 621 | + | ||
| 622 | + The base implementation returns ``None``. Subclasses may return another | ||
| 623 | + value for compatibility with existing overrides, but callers should treat | ||
| 624 | + the return value as unspecified. | ||
| 621 | 625 | """ | |
| 622 | 626 | # handle | |
| 623 | 627 | # Counting objects: 4, done. | |
@@ -632,7 +636,7 @@ def _parse_progress_line(self, line: AnyStr) -> None: | |||
| 632 | 636 | ||
| 633 | 637 | if self._cur_line.startswith(("error:", "fatal:")): | |
| 634 | 638 | self.error_lines.append(self._cur_line) | |
| 635 | - return | ||
| 639 | + return None | ||
| 636 | 640 | ||
| 637 | 641 | cur_count, max_count = None, None | |
| 638 | 642 | match = self.re_op_relative.match(line_str) | |
@@ -642,7 +646,7 @@ def _parse_progress_line(self, line: AnyStr) -> None: | |||
| 642 | 646 | if not match: | |
| 643 | 647 | self.line_dropped(line_str) | |
| 644 | 648 | self.other_lines.append(line_str) | |
| 645 | - return | ||
| 649 | + return None | ||
| 646 | 650 | # END could not get match | |
| 647 | 651 | ||
| 648 | 652 | op_code = 0 | |
@@ -673,7 +677,7 @@ def _parse_progress_line(self, line: AnyStr) -> None: | |||
| 673 | 677 | self.line_dropped(line_str) | |
| 674 | 678 | # Note: Don't add this line to the other lines, as we have to silently | |
| 675 | 679 | # drop it. | |
| 676 | - return | ||
| 680 | + return None | ||
| 677 | 681 | # END handle op code | |
| 678 | 682 | ||
| 679 | 683 | # Figure out stage. | |
@@ -699,6 +703,7 @@ def _parse_progress_line(self, line: AnyStr) -> None: | |||
| 699 | 703 | max_count and float(max_count), | |
| 700 | 704 | message, | |
| 701 | 705 | ) | |
| 706 | + return None | ||
| 702 | 707 | ||
| 703 | 708 | def new_message_handler(self) -> Callable[[str], None]: | |
| 704 | 709 | """ | |
@@ -708,7 +713,7 @@ def new_message_handler(self) -> Callable[[str], None]: | |||
| 708 | 713 | """ | |
| 709 | 714 | ||
| 710 | 715 | def handler(line: AnyStr) -> None: | |
| 711 | - return self._parse_progress_line(line.rstrip()) | ||
| 716 | + self._parse_progress_line(line.rstrip()) | ||
| 712 | 717 | ||
| 713 | 718 | # END handler | |
| 714 | 719 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,19 @@ | |||
| 1 | + # This module is part of GitPython and is released under the | ||
| 2 | + # 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/ | ||
| 3 | + | ||
| 4 | + """Tests for static characteristics of remote progress helpers.""" | ||
| 5 | + | ||
| 6 | + from typing import AnyStr | ||
| 7 | + | ||
| 8 | + from git import RemoteProgress | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + def test_parse_progress_line_override_can_return_non_none() -> None: | ||
| 12 | + """Subclass overrides may return a value without violating base typing.""" | ||
| 13 | + | ||
| 14 | + class ReturningProgress(RemoteProgress): | ||
| 15 | + def _parse_progress_line(self, line: AnyStr) -> str: | ||
| 16 | + super()._parse_progress_line(line) | ||
| 17 | + return "handled" | ||
| 18 | + | ||
| 19 | + assert ReturningProgress()._parse_progress_line("unmatched progress") == "handled" | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments