GeezerVison is showing github.com — Use LBYL for imports where EAFP is a mypy type error · gitpython-developers/GitPython@5778b7a
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: git/objects/blob.py +4-3Lines changed: 4 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 4 | 4 | # 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/ | 5 | 5 |
| 6 | 6 | from mimetypes import guess_type | 7 | | -from . import base | | 7 | +import sys | 8 | 8 |
| | 9 | +from . import base | 9 | 10 |
| 10 | | -try: | | 11 | +if sys.version_info >= (3, 8): | 11 | 12 | from typing import Literal | 12 | | -except ImportError: | | 13 | +else: | 13 | 14 | from typing_extensions import Literal | 14 | 15 |
| 15 | 16 | __all__ = ("Blob",) | |
Collapse file Copy file name to clipboardExpand all lines: git/objects/commit.py +19-19Lines changed: 19 additions & 19 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | # This module is part of GitPython and is released under the | 4 | 4 | # 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/ | 5 | 5 |
| | 6 | +from collections import defaultdict | 6 | 7 | import datetime | | 8 | +from io import BytesIO | | 9 | +import logging | | 10 | +import os | 7 | 11 | import re | 8 | 12 | from subprocess import Popen, PIPE | | 13 | +import sys | | 14 | +from time import altzone, daylight, localtime, time, timezone | | 15 | + | 9 | 16 | from gitdb import IStream | 10 | | -from git.util import hex_to_bin, Actor, Stats, finalize_process | 11 | | -from git.diff import Diffable | 12 | 17 | from git.cmd import Git | | 18 | +from git.diff import Diffable | | 19 | +from git.util import hex_to_bin, Actor, Stats, finalize_process | 13 | 20 |
| 14 | 21 | from .tree import Tree | 15 | | -from . import base | 16 | 22 | from .util import ( | 17 | 23 | Serializable, | 18 | 24 | TraversableIterableObj, | 19 | | - parse_date, | 20 | 25 | altz_to_utctz_str, | 21 | | - parse_actor_and_date, | 22 | 26 | from_timestamp, | | 27 | + parse_actor_and_date, | | 28 | + parse_date, | 23 | 29 | ) | 24 | | - | 25 | | -from time import time, daylight, altzone, timezone, localtime | 26 | | -import os | 27 | | -from io import BytesIO | 28 | | -import logging | 29 | | -from collections import defaultdict | 30 | | - | | 30 | +from . import base | 31 | 31 |
| 32 | 32 | # typing ------------------------------------------------------------------ | 33 | 33 |
| 34 | 34 | from typing import ( | 35 | 35 | Any, | | 36 | + Dict, | 36 | 37 | IO, | 37 | 38 | Iterator, | 38 | 39 | List, | 39 | 40 | Sequence, | 40 | 41 | Tuple, | 41 | | - Union, | 42 | 42 | TYPE_CHECKING, | | 43 | + Union, | 43 | 44 | cast, | 44 | | - Dict, | 45 | 45 | ) | 46 | 46 |
| 47 | | -from git.types import PathLike | 48 | | - | 49 | | -try: | | 47 | +if sys.version_info >= (3, 8): | 50 | 48 | from typing import Literal | 51 | | -except ImportError: | | 49 | +else: | 52 | 50 | from typing_extensions import Literal | 53 | 51 |
| | 52 | +from git.types import PathLike | | 53 | + | 54 | 54 | if TYPE_CHECKING: | 55 | | - from git.repo import Repo | 56 | 55 | from git.refs import SymbolicReference | | 56 | + from git.repo import Repo | 57 | 57 |
| 58 | 58 | # ------------------------------------------------------------------------ | 59 | 59 |
| |
Collapse file Copy file name to clipboardExpand all lines: git/objects/submodule/base.py +4-5Lines changed: 4 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 39 | 39 | sm_section, | 40 | 40 | ) | 41 | 41 |
| 42 | | - | 43 | 42 | # typing ---------------------------------------------------------------------- | 44 | 43 |
| 45 | 44 | from typing import ( | | 54 | 53 | cast, | 55 | 54 | ) | 56 | 55 |
| 57 | | -from git.types import Commit_ish, PathLike, TBD | 58 | | - | 59 | | -try: | | 56 | +if sys.version_info >= (3, 8): | 60 | 57 | from typing import Literal | 61 | | -except ImportError: | | 58 | +else: | 62 | 59 | from typing_extensions import Literal | 63 | 60 |
| | 61 | +from git.types import Commit_ish, PathLike, TBD | | 62 | + | 64 | 63 | if TYPE_CHECKING: | 65 | 64 | from git.index import IndexFile | 66 | 65 | from git.objects.commit import Commit | |
Collapse file Copy file name to clipboardExpand all lines: git/objects/tag.py +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 | For lightweight tags, see the :mod:`git.refs.tag` module. | 10 | 10 | """ | 11 | 11 |
| | 12 | +import sys | | 13 | + | 12 | 14 | from . import base | 13 | 15 | from .util import get_object_type_by_name, parse_actor_and_date | 14 | 16 | from ..util import hex_to_bin | 15 | 17 | from ..compat import defenc | 16 | 18 |
| 17 | 19 | from typing import List, TYPE_CHECKING, Union | 18 | 20 |
| 19 | | -try: | | 21 | +if sys.version_info >= (3, 8): | 20 | 22 | from typing import Literal | 21 | | -except ImportError: | | 23 | +else: | 22 | 24 | from typing_extensions import Literal | 23 | 25 |
| 24 | 26 | if TYPE_CHECKING: | |
Collapse file Copy file name to clipboardExpand all lines: git/objects/tree.py +12-13Lines changed: 12 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | # This module is part of GitPython and is released under the | 4 | 4 | # 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/ | 5 | 5 |
| 6 | | -from git.util import IterableList, join_path | | 6 | +import sys | | 7 | + | 7 | 8 | import git.diff as git_diff | 8 | | -from git.util import to_bin_sha | | 9 | +from git.util import IterableList, join_path, to_bin_sha | 9 | 10 |
| 10 | | -from . import util | 11 | | -from .base import IndexObject, IndexObjUnion | | 11 | +from .base import IndexObjUnion, IndexObject | 12 | 12 | from .blob import Blob | 13 | | -from .submodule.base import Submodule | 14 | | - | 15 | 13 | from .fun import tree_entries_from_data, tree_to_stream | 16 | | - | | 14 | +from .submodule.base import Submodule | | 15 | +from . import util | 17 | 16 |
| 18 | 17 | # typing ------------------------------------------------- | 19 | 18 |
| | 25 | 24 | Iterator, | 26 | 25 | List, | 27 | 26 | Tuple, | | 27 | + TYPE_CHECKING, | 28 | 28 | Type, | 29 | 29 | Union, | 30 | 30 | cast, | 31 | | - TYPE_CHECKING, | 32 | 31 | ) | 33 | 32 |
| 34 | | -from git.types import PathLike | 35 | | - | 36 | | -try: | | 33 | +if sys.version_info >= (3, 8): | 37 | 34 | from typing import Literal | 38 | | -except ImportError: | | 35 | +else: | 39 | 36 | from typing_extensions import Literal | 40 | 37 |
| | 38 | +from git.types import PathLike | | 39 | + | 41 | 40 | if TYPE_CHECKING: | 42 | | - from git.repo import Repo | 43 | 41 | from io import BytesIO | | 42 | + from git.repo import Repo | 44 | 43 |
| 45 | 44 | TreeCacheTup = Tuple[bytes, int, str] | 46 | 45 |
| |
|