| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7204cc1 commit 2f5e258
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,7 +28,7 @@ | |||
| 28 | 28 | TYPE_CHECKING, | |
| 29 | 29 | cast, | |
| 30 | 30 | ) | |
| 31 | - from git.types import PathLike, Literal | ||
| 31 | + from git.types import Literal, PathLike, final | ||
| 32 | 32 | ||
| 33 | 33 | if TYPE_CHECKING: | |
| 34 | 34 | from .objects.tree import Tree | |
@@ -94,13 +94,14 @@ class Diffable: | |||
| 94 | 94 | repo: "Repo" | |
| 95 | 95 | """Repository to operate on. Must be provided by subclass or sibling class.""" | |
| 96 | 96 | ||
| 97 | + @final | ||
| 97 | 98 | class Index: | |
| 98 | 99 | """Stand-in indicating you want to diff against the index.""" | |
| 99 | 100 | ||
| 100 | 101 | def _process_diff_args( | |
| 101 | 102 | self, | |
| 102 | - args: List[Union[PathLike, "Diffable", Type["Index"]]], | ||
| 103 | - ) -> List[Union[PathLike, "Diffable", Type["Index"]]]: | ||
| 103 | + args: List[Union[PathLike, "Diffable"]], | ||
| 104 | + ) -> List[Union[PathLike, "Diffable"]]: | ||
| 104 | 105 | """ | |
| 105 | 106 | :return: | |
| 106 | 107 | Possibly altered version of the given args list. | |
@@ -161,7 +162,7 @@ def diff( | |||
| 161 | 162 | :class:`~git.objects.tree.Tree` or :class:`~git.objects.commit.Commit`, or a | |
| 162 | 163 | git command error will occur. | |
| 163 | 164 | """ | |
| 164 | - args: List[Union[PathLike, Diffable, Type["Diffable.Index"]]] = [] | ||
| 165 | + args: List[Union[PathLike, Diffable]] = [] | ||
| 165 | 166 | args.append("--abbrev=40") # We need full shas. | |
| 166 | 167 | args.append("--full-index") # Get full index paths, not only filenames. | |
| 167 | 168 | ||
@@ -184,7 +185,7 @@ def diff( | |||
| 184 | 185 | paths = [paths] | |
| 185 | 186 | ||
| 186 | 187 | diff_cmd = self.repo.git.diff | |
| 187 | - if other is self.Index: | ||
| 188 | + if other is Diffable.Index: | ||
| 188 | 189 | args.insert(0, "--cached") | |
| 189 | 190 | elif other is NULL_TREE: | |
| 190 | 191 | args.insert(0, "-r") # Recursive diff-tree. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -645,8 +645,8 @@ def write_tree(self) -> Tree: | |||
| 645 | 645 | ||
| 646 | 646 | def _process_diff_args( | |
| 647 | 647 | self, | |
| 648 | - args: List[Union[PathLike, "git_diff.Diffable", Type["git_diff.Diffable.Index"]]], | ||
| 649 | - ) -> List[Union[PathLike, "git_diff.Diffable", Type["git_diff.Diffable.Index"]]]: | ||
| 648 | + args: List[Union[PathLike, "git_diff.Diffable"]], | ||
| 649 | + ) -> List[Union[PathLike, "git_diff.Diffable"]]: | ||
| 650 | 650 | try: | |
| 651 | 651 | args.pop(args.index(self)) | |
| 652 | 652 | except IndexError: | |
@@ -1494,7 +1494,6 @@ def diff( | |||
| 1494 | 1494 | Will only work with indices that represent the default git index as they | |
| 1495 | 1495 | have not been initialized with a stream. | |
| 1496 | 1496 | """ | |
| 1497 | - | ||
| 1498 | 1497 | # Only run if we are the default repository index. | |
| 1499 | 1498 | if self._file_path != self._index_path(): | |
| 1500 | 1499 | raise AssertionError("Cannot call %r on indices that do not represent the default git index" % self.diff()) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,7 @@ | |||
| 22 | 22 | TypedDict, | |
| 23 | 23 | Protocol, | |
| 24 | 24 | SupportsIndex as SupportsIndex, | |
| 25 | + final, | ||
| 25 | 26 | runtime_checkable, | |
| 26 | 27 | ) | |
| 27 | 28 | else: | |
@@ -30,6 +31,7 @@ | |||
| 30 | 31 | SupportsIndex as SupportsIndex, | |
| 31 | 32 | TypedDict, | |
| 32 | 33 | Protocol, | |
| 34 | + final, | ||
| 33 | 35 | runtime_checkable, | |
| 34 | 36 | ) | |
| 35 | 37 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments