◐ Shell
reader mode source ↗
Skip to content
Merged
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
9 changes: 2 additions & 7 deletions git/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@

"""Utilities to help provide compatibility with Python 3."""

# flake8: noqa

import locale
import os
import sys

from gitdb.utils.encoding import (
force_bytes, # @UnusedImport
force_text, # @UnusedImport
)

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

from typing import (
Any,
AnyStr,
Dict,
Expand Down
6 changes: 2 additions & 4 deletions git/index/__init__.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,5 @@

"""Initialize the index package."""

# flake8: noqa

from .base import *
from .typ import *
20 changes: 9 additions & 11 deletions git/objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@

"""Import all submodules' main classes into the package space."""

# flake8: noqa

import inspect

from .base import *
from .blob import *
from .commit import *
from .submodule import util as smutil
from .submodule.base import *
from .submodule.root import *
from .tag import *
from .tree import *

# Fix import dependency - add IndexObject to the util module, so that it can be
# imported by the submodule.base.
smutil.IndexObject = IndexObject # type: ignore[attr-defined]
smutil.Object = Object # type: ignore[attr-defined]
del smutil

# Must come after submodule was made available.
14 changes: 7 additions & 7 deletions git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ def move(self, module_path: PathLike, configuration: bool = True, module: bool =
raise
# END handle undo rename

# Auto-rename submodule if it's name was 'default', that is, the checkout directory.
if previous_sm_path == self.name:
self.rename(module_checkout_path)

Expand All @@ -976,19 +976,19 @@ def remove(
from the .gitmodules file and the entry in the .git/config file.

:param module: If True, the checked out module we point to will be deleted as
well.If that module is currently on a commit outside any branch in the
remote, or if it is ahead of its tracking branch, or if there are modified
or untracked files in its working tree, then the removal will fail.
In case the removal of the repository fails for these reasons, the
submodule status will not have been altered.
If this submodule has child modules of its own, these will be deleted prior
to touching the direct submodule.
:param force: Enforces the deletion of the module even though it contains
modifications. This basically enforces a brute-force file system based
deletion.
:param configuration: If True, the submodule is deleted from the configuration,
otherwise it isn't. Although this should be enabled most of the time,
this flag enables you to safely delete the repository of your submodule.
:param dry_run: If True, we will not actually do anything, but throw the errors
we would usually throw.
:return: self
Expand Down
22 changes: 9 additions & 13 deletions git/objects/util.py
Original file line number Diff line number Diff line change
@@ -5,31 +5,27 @@

"""General utility functions."""

# flake8: noqa F401


from abc import ABC, abstractmethod
import warnings
from git.util import IterableList, IterableObj, Actor

import re
from collections import deque

from string import digits
import time
import calendar
from datetime import datetime, timedelta, tzinfo

# typing ------------------------------------------------------------
from typing import (
Any,
Callable,
Deque,
Iterator,
Generic,
NamedTuple,
overload,
Sequence, # NOQA: F401
TYPE_CHECKING,
Tuple,
Type,
Expand All @@ -38,7 +34,7 @@
cast,
)

from git.types import Has_id_attribute, Literal, _T # NOQA: F401

if TYPE_CHECKING:
from io import BytesIO, StringIO
Expand Down
13 changes: 6 additions & 7 deletions git/refs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# This module is part of GitPython and is released under the
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/

# flake8: noqa
# Import all modules in order, fix the names they require.

from .symbolic import *
from .reference import *
from .head import *
from .tag import *
from .remote import *

from .log import *
4 changes: 2 additions & 2 deletions git/refs/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
from git.types import PathLike

if TYPE_CHECKING:
from git.refs import SymbolicReference
from io import BytesIO
from git.config import GitConfigParser, SectionConstraint # NOQA

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

Expand Down
4 changes: 2 additions & 2 deletions git/refs/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

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

from typing import Any, Callable, Iterator, Type, Union, TYPE_CHECKING # NOQA
from git.types import Commit_ish, PathLike, _T # NOQA

if TYPE_CHECKING:
from git.repo import Repo
Expand Down
5 changes: 2 additions & 3 deletions git/refs/symbolic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This module is part of GitPython and is released under the
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/

from git.types import PathLike
import os

from git.compat import defenc
Expand Down Expand Up @@ -31,8 +30,8 @@
Union,
TYPE_CHECKING,
cast,
) # NOQA
from git.types import Commit_ish, PathLike # NOQA

if TYPE_CHECKING:
from git.repo import Repo
Expand Down
4 changes: 1 addition & 3 deletions git/repo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@

"""Initialize the Repo package."""

# flake8: noqa

from .base import Repo as Repo
14 changes: 6 additions & 8 deletions git/types.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# This module is part of GitPython and is released under the
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/

# flake8: noqa

import os
import sys
from typing import (
Dict,
NoReturn,
Sequence as Sequence,
Expand All @@ -16,24 +14,24 @@
Callable,
TYPE_CHECKING,
TypeVar,
) # noqa: F401

if sys.version_info >= (3, 8):
from typing import (
Literal,
TypedDict,
Protocol,
SupportsIndex as SupportsIndex,
runtime_checkable,
) # noqa: F401
else:
from typing_extensions import (
Literal,
SupportsIndex as SupportsIndex,
TypedDict,
Protocol,
runtime_checkable,
) # noqa: F401

# if sys.version_info >= (3, 10):
# from typing import TypeGuard # noqa: F401
Expand Down
8 changes: 4 additions & 4 deletions git/util.py
Original file line number Diff line number Diff line change
@@ -62,12 +62,9 @@
Has_id_attribute,
)

T_IterableObj = TypeVar("T_IterableObj", bound=Union["IterableObj", "Has_id_attribute"], covariant=True)
# So IterableList[Head] is subtype of IterableList[IterableObj]

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

from gitdb.util import ( # NOQA @IgnorePep8
make_sha,
LockedFD, # @UnusedImport
file_contents_ro, # @UnusedImport
Expand All @@ -79,6 +76,9 @@
hex_to_bin, # @UnusedImport
)

# NOTE: Some of the unused imports might be used/imported by others.
# Handle once test-cases are back up and running.
# Most of these are unused here, but are for use by git-python modules so these
Expand Down
4 changes: 2 additions & 2 deletions test/lib/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def repo_creator(self):
os.chdir(rw_repo.working_dir)
try:
return func(self, rw_repo)
except: # noqa E722
log.info("Keeping repo after failure: %s", repo_dir)
repo_dir = None
raise
Expand Down Expand Up @@ -305,7 +305,7 @@ def remote_repo_creator(self):
with cwd(rw_repo.working_dir):
try:
return func(self, rw_repo, rw_daemon_repo)
except: # noqa E722
log.info(
"Keeping repos after failure: \n rw_repo_dir: %s \n rw_daemon_repo_dir: %s",
rw_repo_dir,
Expand Down
2 changes: 1 addition & 1 deletion test/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def test_datetimes(self):
commit.authored_datetime,
datetime(2009, 10, 8, 18, 17, 5, tzinfo=tzoffset(-7200)),
commit.authored_datetime,
) # noqa
self.assertEqual(
commit.authored_datetime,
datetime(2009, 10, 8, 16, 17, 5, tzinfo=utc),
Expand Down
Loading
Toggle all file notes Toggle all file annotations