diff options
author | Yobmod <yobmod@gmail.com> | 2021-07-05 12:31:00 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-07-05 12:31:00 +0100 |
commit | 16f0607ed29f20c09e89f2cacc0e28e982309d60 (patch) | |
tree | 1827bb53f17af0142e23530c20e49403dfc5b7ed /git/repo/base.py | |
parent | d4a9eab9ddc64a18b33ac04a4224f347ccdc78de (diff) | |
download | gitpython-16f0607ed29f20c09e89f2cacc0e28e982309d60.tar.gz |
Improve typing of config_levels, add assert_never()
Diffstat (limited to 'git/repo/base.py')
-rw-r--r-- | git/repo/base.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/git/repo/base.py b/git/repo/base.py index d77b19c1..e60b6f6c 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -36,13 +36,15 @@ import gitdb # typing ------------------------------------------------------ -from git.types import TBD, PathLike, Lit_config_levels, Commit_ish, Tree_ish +from git.types import ConfigLevels_NT, TBD, PathLike, Lit_config_levels, Commit_ish, Tree_ish from typing import (Any, BinaryIO, Callable, Dict, Iterator, List, Mapping, Optional, Sequence, TextIO, Tuple, Type, Union, NamedTuple, cast, TYPE_CHECKING) -if TYPE_CHECKING: # only needed for types +from git.types import ConfigLevels_Tup + +if TYPE_CHECKING: from git.util import IterableList from git.refs.symbolic import SymbolicReference from git.objects import Tree @@ -55,12 +57,11 @@ log = logging.getLogger(__name__) __all__ = ('Repo',) -BlameEntry = NamedTuple('BlameEntry', [ - ('commit', Dict[str, TBD]), - ('linenos', range), - ('orig_path', Optional[str]), - ('orig_linenos', range)] -) +class BlameEntry(NamedTuple): + commit: Dict[str, TBD] + linenos: range + orig_path: Optional[str] + orig_linenos: range class Repo(object): @@ -95,7 +96,7 @@ class Repo(object): # invariants # represents the configuration level of a configuration file - config_level = ("system", "user", "global", "repository") # type: Tuple[Lit_config_levels, ...] + config_level: ConfigLevels_Tup = ConfigLevels_NT("system", "user", "global", "repository") # Subclass configuration # Subclasses may easily bring in their own custom types by placing a constructor or type here |