| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -323,7 +323,7 @@ def traverse(self, # type: ignore # overrides super() | |||
| 323 | 323 | super(Tree, self).traverse(predicate, prune, depth, # type: ignore | |
| 324 | 324 | branch_first, visit_once, ignore_self)) | |
| 325 | 325 | ||
| 326 | - def list_traverse(self, *args: Any, **kwargs: Any) -> IterableList[Union['Tree', 'Submodule', 'Blob']]: | ||
| 326 | + def list_traverse(self, *args: Any, **kwargs: Any) -> IterableList[IndexObjUnion]: | ||
| 327 | 327 | return super(Tree, self).list_traverse(* args, **kwargs) | |
| 328 | 328 | ||
| 329 | 329 | # List protocol | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,13 +19,11 @@ | |||
| 19 | 19 | import calendar | |
| 20 | 20 | from datetime import datetime, timedelta, tzinfo | |
| 21 | 21 | ||
| 22 | - from git.objects.base import IndexObject # just for an isinstance check | ||
| 23 | - | ||
| 24 | 22 | # typing ------------------------------------------------------------ | |
| 25 | 23 | from typing import (Any, Callable, Deque, Iterator, NamedTuple, overload, Sequence, | |
| 26 | 24 | TYPE_CHECKING, Tuple, Type, TypeVar, Union, cast) | |
| 27 | 25 | ||
| 28 | - from git.types import Literal | ||
| 26 | + from git.types import Has_id_attribute, Literal | ||
| 29 | 27 | ||
| 30 | 28 | if TYPE_CHECKING: | |
| 31 | 29 | from io import BytesIO, StringIO | |
@@ -319,7 +317,7 @@ def list_traverse(self, *args: Any, **kwargs: Any) -> IterableList[Union['Commit | |||
| 319 | 317 | """ | |
| 320 | 318 | # Commit and Submodule have id.__attribute__ as IterableObj | |
| 321 | 319 | # Tree has id.__attribute__ inherited from IndexObject | |
| 322 | - if isinstance(self, (TraversableIterableObj, IndexObject)): | ||
| 320 | + if isinstance(self, (TraversableIterableObj, Has_id_attribute)): | ||
| 323 | 321 | id = self._id_attribute_ | |
| 324 | 322 | else: | |
| 325 | 323 | id = "" # shouldn't reach here, unless Traversable subclass created with no _id_attribute_ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,9 +11,9 @@ | |||
| 11 | 11 | from git.repo import Repo | |
| 12 | 12 | ||
| 13 | 13 | if sys.version_info[:2] >= (3, 8): | |
| 14 | - from typing import Final, Literal, SupportsIndex, TypedDict, Protocol # noqa: F401 | ||
| 14 | + from typing import Final, Literal, SupportsIndex, TypedDict, Protocol, runtime_checkable # noqa: F401 | ||
| 15 | 15 | else: | |
| 16 | - from typing_extensions import Final, Literal, SupportsIndex, TypedDict, Protocol # noqa: F401 | ||
| 16 | + from typing_extensions import Final, Literal, SupportsIndex, TypedDict, Protocol, runtime_checkable # noqa: F401 | ||
| 17 | 17 | ||
| 18 | 18 | if sys.version_info[:2] >= (3, 10): | |
| 19 | 19 | from typing import TypeGuard # noqa: F401 | |
@@ -73,5 +73,11 @@ class HSH_TD(TypedDict): | |||
| 73 | 73 | files: Dict[PathLike, Files_TD] | |
| 74 | 74 | ||
| 75 | 75 | ||
| 76 | + @runtime_checkable | ||
| 76 | 77 | class Has_Repo(Protocol): | |
| 77 | 78 | repo: 'Repo' | |
| 79 | + | ||
| 80 | + | ||
| 81 | + @runtime_checkable | ||
| 82 | + class Has_id_attribute(Protocol): | ||
| 83 | + _id_attribute_: str | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments