summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git/objects/util.py4
-rw-r--r--git/refs/symbolic.py12
-rw-r--r--git/repo/__init__.py2
-rw-r--r--git/repo/base.py9
-rw-r--r--git/util.py2
-rw-r--r--pyproject.toml3
6 files changed, 18 insertions, 14 deletions
diff --git a/git/objects/util.py b/git/objects/util.py
index 0b843301..16d4c0ac 100644
--- a/git/objects/util.py
+++ b/git/objects/util.py
@@ -187,9 +187,7 @@ def parse_date(string_date: Union[str, datetime]) -> Tuple[int, int]:
offset = -int(utcoffset.total_seconds())
return int(string_date.astimezone(utc).timestamp()), offset
else:
- # should just return timestamp, 0?
- return int(string_date.astimezone(utc).timestamp()), 0
- # raise ValueError(f"string_date datetime object without tzinfo, {string_date}")
+ raise ValueError(f"string_date datetime object without tzinfo, {string_date}")
# git time
try:
diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py
index 1c56c043..238be839 100644
--- a/git/refs/symbolic.py
+++ b/git/refs/symbolic.py
@@ -72,12 +72,13 @@ class SymbolicReference(object):
def __repr__(self) -> str:
return '<git.%s "%s">' % (self.__class__.__name__, self.path)
- def __eq__(self, other: Any) -> bool:
+ def __eq__(self, other: object) -> bool:
if hasattr(other, 'path'):
+ other = cast(SymbolicReference, other)
return self.path == other.path
return False
- def __ne__(self, other: Any) -> bool:
+ def __ne__(self, other: object) -> bool:
return not (self == other)
def __hash__(self) -> int:
@@ -364,8 +365,9 @@ class SymbolicReference(object):
return self
# aliased reference
+ reference: Union['Head', 'TagReference', 'RemoteReference', 'Reference']
reference = property(_get_reference, set_reference, doc="Returns the Reference we point to") # type: ignore
- ref: Union['Head', 'TagReference', 'RemoteReference', 'Reference'] = reference # type: ignore
+ ref = reference
def is_valid(self) -> bool:
"""
@@ -699,7 +701,9 @@ class SymbolicReference(object):
instance = ref_type(repo, path)
if instance.__class__ == SymbolicReference and instance.is_detached:
raise ValueError("SymbolRef was detached, we drop it")
- return instance
+ else:
+ assert isinstance(instance, Reference), "instance should be Reference or subtype"
+ return instance
except ValueError:
pass
# END exception handling
diff --git a/git/repo/__init__.py b/git/repo/__init__.py
index 712df60d..23c18db8 100644
--- a/git/repo/__init__.py
+++ b/git/repo/__init__.py
@@ -1,3 +1,3 @@
"""Initialize the Repo package"""
# flake8: noqa
-from .base import *
+from .base import Repo as Repo
diff --git a/git/repo/base.py b/git/repo/base.py
index 2609bf55..6708872e 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -3,6 +3,7 @@
#
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
+from __future__ import annotations
import logging
import os
import re
@@ -384,13 +385,13 @@ class Repo(object):
:return: created submodules"""
return Submodule.add(self, *args, **kwargs)
- def iter_submodules(self, *args: Any, **kwargs: Any) -> Iterator:
+ def iter_submodules(self, *args: Any, **kwargs: Any) -> Iterator[Submodule]:
"""An iterator yielding Submodule instances, see Traversable interface
for a description of args and kwargs
:return: Iterator"""
return RootModule(self).traverse(*args, **kwargs)
- def submodule_update(self, *args: Any, **kwargs: Any) -> Iterator:
+ def submodule_update(self, *args: Any, **kwargs: Any) -> Iterator[Submodule]:
"""Update the submodules, keeping the repository consistent as it will
take the previous state into consideration. For more information, please
see the documentation of RootModule.update"""
@@ -774,7 +775,7 @@ class Repo(object):
finalize_process(proc)
return untracked_files
- def ignored(self, *paths: PathLike) -> List[PathLike]:
+ def ignored(self, *paths: PathLike) -> List[str]:
"""Checks if paths are ignored via .gitignore
Doing so using the "git check-ignore" method.
@@ -782,7 +783,7 @@ class Repo(object):
:return: subset of those paths which are ignored
"""
try:
- proc = self.git.check_ignore(*paths)
+ proc: str = self.git.check_ignore(*paths)
except GitCommandError:
return []
return proc.replace("\\\\", "\\").replace('"', "").split("\n")
diff --git a/git/util.py b/git/util.py
index c20be6eb..4f82219e 100644
--- a/git/util.py
+++ b/git/util.py
@@ -70,7 +70,7 @@ from gitdb.util import ( # NOQA @IgnorePep8
# Most of these are unused here, but are for use by git-python modules so these
# don't see gitdb all the time. Flake of course doesn't like it.
__all__ = ["stream_copy", "join_path", "to_native_path_linux",
- "join_path_native", "Stats", "IndexFileSHA1Writer", "Iterable", "IterableList",
+ "join_path_native", "Stats", "IndexFileSHA1Writer", "IterableObj", "IterableList",
"BlockingLockFile", "LockFile", 'Actor', 'get_user_id', 'assure_directory_exists',
'RemoteProgress', 'CallableRemoteProgress', 'rmtree', 'unbare_repo',
'HIDE_WINDOWS_KNOWN_ERRORS']
diff --git a/pyproject.toml b/pyproject.toml
index 434880c7..102b6fdc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -22,10 +22,11 @@ filterwarnings = 'ignore::DeprecationWarning'
disallow_untyped_defs = true
no_implicit_optional = true
warn_redundant_casts = true
-implicit_reexport = true
# warn_unused_ignores = true
warn_unreachable = true
show_error_codes = true
+implicit_reexport = true
+# strict = true
# TODO: remove when 'gitdb' is fully annotated
[[tool.mypy.overrides]]