Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcb5688d

Browse files
committed
Readd with_metaclass shim
1 parentd812818 commitcb5688d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

‎git/compat.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,19 @@ def win_encode(s: Optional[AnyStr]) -> Optional[bytes]:
9797
elifsisnotNone:
9898
raiseTypeError('Expected bytes or text, but got %r'% (s,))
9999
returnNone
100+
101+
102+
# type: ignore ## mypy cannot understand dynamic class creation
103+
defwith_metaclass(meta:Type[Any],*bases:Any)->TBD:
104+
"""copied from https://github.com/Byron/bcore/blob/master/src/python/butility/future.py#L15"""
105+
106+
classmetaclass(meta):# type: ignore
107+
__call__=type.__call__
108+
__init__=type.__init__# type: ignore
109+
110+
def__new__(cls,name:str,nbases:Optional[Tuple[int, ...]],d:Dict[str,Any])->TBD:
111+
ifnbasesisNone:
112+
returntype.__new__(cls,name, (),d)
113+
returnmeta(name,bases,d)
114+
115+
returnmetaclass(meta.__name__+'Helper',None, {})# type: ignore

‎git/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
defenc,
2020
force_text,
2121
is_win,
22+
with_metaclass,
2223
)
2324

2425
fromgit.utilimportLockFile
@@ -228,7 +229,7 @@ def get_config_path(config_level: Lit_config_levels) -> str:
228229
assert_never(config_level,ValueError(f"Invalid configuration level:{config_level!r}"))
229230

230231

231-
classGitConfigParser(cp.RawConfigParser,metaclass=MetaParserBuilder):
232+
classGitConfigParser(with_metaclass(MetaParserBuilder,cp.RawConfigParser)):# type: ignore ## mypy does not understand dynamic class creation # noqa: E501
232233

233234
"""Implements specifics required to read git style configuration files.
234235

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp