diff options
author | Yobmod <yobmod@gmail.com> | 2021-07-24 22:34:20 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-07-24 22:34:20 +0100 |
commit | 6d6aae11af2f1acc6aa384ed43e6897da8fe7057 (patch) | |
tree | 0606f5a67d5c46d6b60abccffdcea19079084d97 | |
parent | 981cfa8d6161d83383610733cf86487ced7a4e6c (diff) | |
download | gitpython-6d6aae11af2f1acc6aa384ed43e6897da8fe7057.tar.gz |
fix rdereddict, cannot subclass typing-extensiosn version
-rw-r--r-- | git/config.py | 14 | ||||
-rw-r--r-- | git/types.py | 4 |
2 files changed, 14 insertions, 4 deletions
diff --git a/git/config.py b/git/config.py index c4303270..51744bfe 100644 --- a/git/config.py +++ b/git/config.py @@ -6,6 +6,7 @@ """Module containing module parser implementation able to properly read and write configuration files""" +import sys import abc from functools import wraps import inspect @@ -33,13 +34,21 @@ import configparser as cp from typing import (Any, Callable, Generic, IO, List, Dict, Sequence, TYPE_CHECKING, Tuple, TypeVar, Union, cast, overload) -from git.types import Lit_config_levels, ConfigLevels_Tup, OrderedDict, PathLike, TBD, assert_never, _T +from git.types import Lit_config_levels, ConfigLevels_Tup, PathLike, TBD, assert_never, _T if TYPE_CHECKING: from git.repo.base import Repo from io import BytesIO T_ConfigParser = TypeVar('T_ConfigParser', bound='GitConfigParser') + +if sys.version_info[:2] < (3, 7): + from collections import OrderedDict + OrderedDict_OMD = OrderedDict +else: + from typing import OrderedDict + OrderedDict_OMD = OrderedDict[str, List[_T]] + # ------------------------------------------------------------- __all__ = ('GitConfigParser', 'SectionConstraint') @@ -164,7 +173,7 @@ class SectionConstraint(Generic[T_ConfigParser]): self._config.__exit__(exception_type, exception_value, traceback) -class _OMD(OrderedDict[str, List[_T]]): +class _OMD(OrderedDict_OMD): """Ordered multi-dict.""" def __setitem__(self, key: str, value: _T) -> None: # type: ignore[override] @@ -617,6 +626,7 @@ class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser)): # if self._defaults: write_section(cp.DEFAULTSECT, self._defaults) + value: TBD for name, value in self._sections.items(): write_section(name, value) diff --git a/git/types.py b/git/types.py index 25608006..ccaffef3 100644 --- a/git/types.py +++ b/git/types.py @@ -8,10 +8,10 @@ from typing import (Callable, Dict, NoReturn, Sequence, Tuple, Union, Any, Itera NamedTuple, TYPE_CHECKING, TypeVar) # noqa: F401 if sys.version_info[:2] >= (3, 8): - from typing import Final, Literal, SupportsIndex, TypedDict, Protocol, runtime_checkable, OrderedDict # noqa: F401 + from typing import Final, Literal, SupportsIndex, TypedDict, Protocol, runtime_checkable # noqa: F401 else: from typing_extensions import (Final, Literal, SupportsIndex, # noqa: F401 - TypedDict, Protocol, runtime_checkable, OrderedDict) # noqa: F401 + TypedDict, Protocol, runtime_checkable) # noqa: F401 # if sys.version_info[:2] >= (3, 10): # from typing import TypeGuard # noqa: F401 |