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

Commit820a2fb

Browse files
committed
Add GitMeta alias
Hopefully no one will ever need it.
1 parent10e0fc2 commit820a2fb

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

‎git/cmd.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from __future__importannotations
77

8-
__all__= ["Git"]
8+
__all__= ["GitMeta","Git"]
99

1010
importcontextlib
1111
importio
@@ -354,6 +354,32 @@ def __setattr(cls, name: str, value: Any) -> Any:
354354
__setattr__=__setattr
355355

356356

357+
GitMeta=_GitMeta
358+
"""Alias of :class:`Git`'s metaclass, whether it is :class:`type` or a custom metaclass.
359+
360+
Whether the :class:`Git` class has the default :class:`type` as its metaclass or uses a
361+
custom metaclass is not documented and may change at any time. This statically checkable
362+
metaclass alias is equivalent at runtime to ``type(Git)``. This should almost never be
363+
used. Code that benefits from it is likely to be remain brittle even if it is used.
364+
365+
In view of the :class:`Git` class's intended use and :class:`Git` objects' dynamic
366+
callable attributes representing git subcommands, it rarely makes sense to inherit from
367+
:class:`Git` at all. Using :class:`Git` in multiple inheritance can be especially tricky
368+
to do correctly. Attempting uses of :class:`Git` where its metaclass is relevant, such
369+
as when a sibling class has an unrelated metaclass and a shared lower bound metaclass
370+
might have to be introduced to solve a metaclass conflict, is not recommended.
371+
372+
:note:
373+
The correct static type of the :class:`Git` class itself, and any subclasses, is
374+
``Type[Git]``. (This can be written as ``type[Git]`` in Python 3.9 later.)
375+
376+
:class:`GitMeta` should never be used in any annotation where ``Type[Git]`` is
377+
intended or otherwise possible to use. This alias is truly only for very rare and
378+
inherently precarious situations where it is necessary to deal with the metaclass
379+
explicitly.
380+
"""
381+
382+
357383
classGit(metaclass=_GitMeta):
358384
"""The Git class manages communication with the Git binary.
359385

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp