diff options
-rw-r--r-- | git/objects/submodule/base.py | 13 | ||||
-rw-r--r-- | git/objects/util.py | 12 | ||||
-rw-r--r-- | pyproject.toml | 2 |
3 files changed, 14 insertions, 13 deletions
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index 14351190..559d2585 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -57,6 +57,7 @@ from git.types import Commit_ish, Literal, PathLike, TBD if TYPE_CHECKING: from git.index import IndexFile from git.repo import Repo + from git.refs import Head # ----------------------------------------------------------------------------- @@ -265,7 +266,7 @@ class Submodule(IndexObject, TraversableIterableObj): # end @classmethod - def _clone_repo(cls, repo, url, path, name, **kwargs): + def _clone_repo(cls, repo: 'Repo', url: str, path: PathLike, name: str, **kwargs: Any) -> 'Repo': """:return: Repo instance of newly cloned repository :param repo: our parent repository :param url: url to clone from @@ -279,7 +280,7 @@ class Submodule(IndexObject, TraversableIterableObj): module_abspath_dir = osp.dirname(module_abspath) if not osp.isdir(module_abspath_dir): os.makedirs(module_abspath_dir) - module_checkout_path = osp.join(repo.working_tree_dir, path) + module_checkout_path = osp.join(str(repo.working_tree_dir), path) # end clone = git.Repo.clone_from(url, module_checkout_path, **kwargs) @@ -484,7 +485,7 @@ class Submodule(IndexObject, TraversableIterableObj): def update(self, recursive: bool = False, init: bool = True, to_latest_revision: bool = False, progress: Union['UpdateProgress', None] = None, dry_run: bool = False, force: bool = False, keep_going: bool = False, env: Union[Mapping[str, str], None] = None, - clone_multi_options: Union[Sequence[TBD], None] = None): + clone_multi_options: Union[Sequence[TBD], None] = None) -> 'Submodule': """Update the repository of this submodule to point to the checkout we point at with the binsha of this instance. @@ -712,7 +713,7 @@ class Submodule(IndexObject, TraversableIterableObj): return self @unbare_repo - def move(self, module_path, configuration=True, module=True): + def move(self, module_path: PathLike, configuration: bool = True, module: bool = True) -> 'Submodule': """Move the submodule to a another module path. This involves physically moving the repository at our current path, changing the configuration, as well as adjusting our index entry accordingly. @@ -742,7 +743,7 @@ class Submodule(IndexObject, TraversableIterableObj): return self # END handle no change - module_checkout_abspath = join_path_native(self.repo.working_tree_dir, module_checkout_path) + module_checkout_abspath = join_path_native(str(self.repo.working_tree_dir), module_checkout_path) if osp.isfile(module_checkout_abspath): raise ValueError("Cannot move repository onto a file: %s" % module_checkout_abspath) # END handle target files @@ -1160,7 +1161,7 @@ class Submodule(IndexObject, TraversableIterableObj): # END handle object state consistency @property - def branch(self): + def branch(self) -> 'Head': """:return: The branch instance that we are to checkout :raise InvalidGitRepositoryError: if our module is not yet checked out""" return mkhead(self.module(), self._branch_path) diff --git a/git/objects/util.py b/git/objects/util.py index db7807c2..f627211e 100644 --- a/git/objects/util.py +++ b/git/objects/util.py @@ -144,20 +144,20 @@ class tzoffset(tzinfo): def __reduce__(self) -> Tuple[Type['tzoffset'], Tuple[float, str]]: return tzoffset, (-self._offset.total_seconds(), self._name) - def utcoffset(self, dt) -> timedelta: + def utcoffset(self, dt: Union[datetime, None]) -> timedelta: return self._offset - def tzname(self, dt) -> str: + def tzname(self, dt: Union[datetime, None]) -> str: return self._name - def dst(self, dt) -> timedelta: + def dst(self, dt: Union[datetime, None]) -> timedelta: return ZERO utc = tzoffset(0, 'UTC') -def from_timestamp(timestamp, tz_offset: float) -> datetime: +def from_timestamp(timestamp: float, tz_offset: float) -> datetime: """Converts a timestamp + tz_offset into an aware datetime instance.""" utc_dt = datetime.fromtimestamp(timestamp, utc) try: @@ -305,7 +305,7 @@ class Traversable(Protocol): @classmethod @abstractmethod - def _get_intermediate_items(cls, item) -> Sequence['Traversable']: + def _get_intermediate_items(cls, item: Any) -> Sequence['Traversable']: """ Returns: Tuple of items connected to the given item. @@ -327,7 +327,7 @@ class Traversable(Protocol): stacklevel=2) return self._list_traverse(*args, **kwargs) - def _list_traverse(self, as_edge=False, *args: Any, **kwargs: Any + def _list_traverse(self, as_edge: bool = False, *args: Any, **kwargs: Any ) -> IterableList[Union['Commit', 'Submodule', 'Tree', 'Blob']]: """ :return: IterableList with the results of the traversal as produced by diff --git a/pyproject.toml b/pyproject.toml index 6437a719..4751ffcb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ filterwarnings = 'ignore::DeprecationWarning' # filterwarnings ignore::WarningType # ignores those warnings [tool.mypy] -# disallow_untyped_defs = true +disallow_untyped_defs = true no_implicit_optional = true warn_redundant_casts = true # warn_unused_ignores = True |