◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
14 changes: 7 additions & 7 deletions git/compat.py
Original file line number Diff line number Diff line change
@@ -14,18 +14,18 @@
import os
import sys

from gitdb.utils.encoding import force_bytes, force_text # noqa: F401 # @UnusedImport

# typing --------------------------------------------------------------------

from typing import ( # noqa: F401
Any,
AnyStr,
Dict,
IO,
Optional,
Tuple,
Type,
Union,
overload,
)
Expand Down
7 changes: 4 additions & 3 deletions git/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

"""Parser for reading and writing configuration files."""

import abc
import configparser as cp
import fnmatch
Expand Down Expand Up @@ -40,9 +42,10 @@
from git.types import Lit_config_levels, ConfigLevels_Tup, PathLike, assert_never, _T

if TYPE_CHECKING:
from git.repo.base import Repo
from io import BytesIO

T_ConfigParser = TypeVar("T_ConfigParser", bound="GitConfigParser")
T_OMD_value = TypeVar("T_OMD_value", str, bytes, int, float, bool)

Expand All @@ -58,8 +61,6 @@

# -------------------------------------------------------------

__all__ = ("GitConfigParser", "SectionConstraint")

_logger = logging.getLogger(__name__)

CONFIG_LEVELS: ConfigLevels_Tup = ("system", "user", "global", "repository")
Expand Down
13 changes: 6 additions & 7 deletions git/db.py
Original file line number Diff line number Diff line change
@@ -3,27 +3,26 @@

"""Module with our own gitdb implementation - it uses the git command."""

from git.util import bin_to_hex, hex_to_bin
from gitdb.base import OInfo, OStream
from gitdb.db import GitDB
from gitdb.db import LooseObjectDB

from gitdb.exc import BadObject
from git.exc import GitCommandError

# typing-------------------------------------------------

from typing import TYPE_CHECKING
from git.types import PathLike

if TYPE_CHECKING:
from git.cmd import Git


# --------------------------------------------------------

__all__ = ("GitCmdObjectDB", "GitDB")


class GitCmdObjectDB(LooseObjectDB):
"""A database representing the default git object store, which includes loose
Expand Down
30 changes: 11 additions & 19 deletions git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
# This module is part of GitPython and is released under the
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/

import enum
import re

from git.cmd import handle_process_output
from git.compat import defenc
from git.util import finalize_process, hex_to_bin

from .objects.blob import Blob
from .objects.util import mode_str_to_int


# typing ------------------------------------------------------------------

from typing import (
Expand All @@ -23,34 +23,27 @@
Match,
Optional,
Tuple,
TypeVar,
Union,
TYPE_CHECKING,
cast,
)
from git.types import Literal, PathLike

if TYPE_CHECKING:
from .objects.tree import Tree
from .objects import Commit
from git.repo.base import Repo
from git.objects.base import IndexObject
from subprocess import Popen
from git import Git

Lit_change_type = Literal["A", "D", "C", "M", "R", "T", "U"]


# def is_change_type(inp: str) -> TypeGuard[Lit_change_type]:
# # return True
# return inp in ['A', 'D', 'C', 'M', 'R', 'T', 'U']

# ------------------------------------------------------------------------


__all__ = ("DiffConstants", "NULL_TREE", "INDEX", "Diffable", "DiffIndex", "Diff")


@enum.unique
class DiffConstants(enum.Enum):
"""Special objects for :meth:`Diffable.diff`.
Expand Down Expand Up @@ -693,7 +686,6 @@ def _handle_diff_line(lines_bytes: bytes, repo: "Repo", index: DiffIndex) -> Non
# Change type can be R100
# R: status letter
# 100: score (in case of copy and rename)
# assert is_change_type(_change_type[0]), f"Unexpected value for change_type received: {_change_type[0]}"
change_type: Lit_change_type = cast(Lit_change_type, _change_type[0])
score_str = "".join(_change_type[1:])
score = int(score_str) if score_str.isdigit() else None
Expand Down
4 changes: 3 additions & 1 deletion git/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@
ParseError,
UnsupportedOperation,
)
from git.compat import safe_decode
from git.util import remove_password_if_present

# typing ----------------------------------------------------

from typing import List, Sequence, Tuple, Union, TYPE_CHECKING
from git.types import PathLike

if TYPE_CHECKING:
Expand Down
13 changes: 11 additions & 2 deletions git/index/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,14 @@

"""Initialize the index package."""

from .base import * # noqa: F401 F403
from .typ import * # noqa: F401 F403
Loading
Toggle all file notes Toggle all file annotations