diff options
author | yobmod <yobmod@gmail.com> | 2021-03-02 21:46:17 +0000 |
---|---|---|
committer | yobmod <yobmod@gmail.com> | 2021-03-02 21:46:17 +0000 |
commit | 2fd9f6ee5c8b4ae4e01a40dc398e2768d838210d (patch) | |
tree | 93a63a1bee90204f68cf41dc08484ad4adab7ad4 /git/compat.py | |
parent | 71e28b8e2ac1b8bc8990454721740b2073829110 (diff) | |
download | gitpython-2fd9f6ee5c8b4ae4e01a40dc398e2768d838210d.tar.gz |
add types to git.compat and git.diff
Diffstat (limited to 'git/compat.py')
-rw-r--r-- | git/compat.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/git/compat.py b/git/compat.py index 8d9e551d..4fe394ae 100644 --- a/git/compat.py +++ b/git/compat.py @@ -10,14 +10,15 @@ import locale import os import sys -from typing import AnyStr, Optional, Type - from gitdb.utils.encoding import ( force_bytes, # @UnusedImport force_text # @UnusedImport ) +from typing import Any, AnyStr, Dict, Optional, Type +from git.types import TBD + is_win = (os.name == 'nt') # type: bool is_posix = (os.name == 'posix') @@ -61,14 +62,17 @@ def win_encode(s: Optional[AnyStr]) -> Optional[bytes]: return None -def with_metaclass(meta, *bases): +def with_metaclass(meta: Type[Any], *bases: Any) -> 'metaclass': # type: ignore ## mypy cannot understand dynamic class creation """copied from https://github.com/Byron/bcore/blob/master/src/python/butility/future.py#L15""" - class metaclass(meta): + + class metaclass(meta): # type: ignore __call__ = type.__call__ - __init__ = type.__init__ + __init__ = type.__init__ # type: ignore - def __new__(cls, name, nbases, d): + def __new__(cls, name: str, nbases: Optional[int], d: Dict[str, Any]) -> TBD: if nbases is None: return type.__new__(cls, name, (), d) return meta(name, bases, d) + return metaclass(meta.__name__ + 'Helper', None, {}) + |