Skip to content
Prev Previous commit
Next Next commit
fix rdereddict, cannot subclass typing-extensiosn version
  • Loading branch information
Yobmod committed Jul 24, 2021
commit 6d6aae11af2f1acc6aa384ed43e6897da8fe7057
14 changes: 12 additions & 2 deletions git/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -33,13 +34,21 @@
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')
Expand Down Expand Up @@ -164,7 +173,7 @@ def __exit__(self, exception_type: str, exception_value: str, traceback: str) ->
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]
Expand Down Expand Up @@ -617,6 +626,7 @@ def write_section(name, section_dict):

if self._defaults:
write_section(cp.DEFAULTSECT, self._defaults)
value: TBD
for name, value in self._sections.items():
write_section(name, value)

Expand Down
4 changes: 2 additions & 2 deletions git/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
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
Expand Down