-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
from github.core.client import * | ||
from github.core.client import __all__ as _client__all__ | ||
from github.core.dummy import * | ||
from github.core.dummy import __all__ as _dummy__all__ | ||
from github.core.errors import * | ||
from github.core.errors import __all__ as _errors__all__ | ||
|
||
|
||
__all__: list[str] = [ # type: ignore[reportUnsupportedDunderAll] | ||
*_client__all__, | ||
*_dummy__all__, | ||
*_errors__all__, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
from __future__ import annotations | ||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from typing import cast | ||
|
||
from github.core import Client | ||
from github.core.http import HTTPClient | ||
from github.interfaces import Type | ||
|
||
import github | ||
from github.utility import MISSING | ||
|
||
|
||
if TYPE_CHECKING: | ||
from typing import Any | ||
else: | ||
Any = object | ||
|
||
|
||
class Dummy(Any): | ||
""" | ||
A lightweight stand-in for GitHub objects. | ||
Parameters | ||
---------- | ||
client: :class:`~github.Client` | ||
Your client. Provide this only when the dummy is acting as a | ||
stand-in for the "self" parameter of an unbound method. | ||
id: :class:`str` | ||
An :attr:`object identifier <github.Node.id>`. | ||
type: :class:`~github.Type` | ||
An object type. This doesn't have a use yet. | ||
Example | ||
------- | ||
.. code-block:: python | ||
label = github.Dummy(id="LA_kwCqcmVwb3NpdG9yeaVsYWJlbA") | ||
pull = github.Dummy(client=client, id="PR_kwCqcmVwb3NpdG9yeaRwdWxs") | ||
await github.Pull.remove_labels(pull, label) | ||
""" | ||
|
||
def __init__( | ||
self, | ||
/, | ||
*, | ||
client: Client = MISSING, | ||
id: str = MISSING, | ||
type: Type = MISSING, | ||
) -> None: | ||
self._client: Client = client | ||
self._id: str = id | ||
self._type: Type = type | ||
|
||
@property | ||
def _data(self, /) -> dict[Any, Any]: | ||
return DummyData() | ||
|
||
@property | ||
def _graphql_fields(self, /) -> dict[str, str] | list[str]: | ||
if self._type is MISSING: | ||
raise AttributeError | ||
|
||
return self._type._graphql_fields | ||
|
||
@property | ||
def _graphql_type(self, /) -> str: | ||
if self._type is MISSING: | ||
raise AttributeError | ||
|
||
return self._type._graphql_type | ||
|
||
@property | ||
def _http(self, /) -> HTTPClient: | ||
if self._client is MISSING: | ||
raise AttributeError | ||
|
||
return self._client._http | ||
|
||
@property | ||
def _node_prefix(self, /) -> str: | ||
if self._type is MISSING: | ||
raise AttributeError | ||
|
||
if not isinstance(self._type, github.Node): | ||
raise AttributeError | ||
|
||
return self._type._node_prefix | ||
|
||
@property | ||
def _repr_fields(self, /) -> list[str]: | ||
if self._type is MISSING: | ||
raise AttributeError | ||
|
||
return self._type._repr_fields | ||
|
||
@property | ||
def id(self, /) -> str: | ||
if self._id is MISSING: | ||
raise AttributeError | ||
|
||
return self._id | ||
|
||
|
||
class DummyData(dict): | ||
def __getitem__(self, key: Any, /) -> Any: | ||
return self | ||
|
||
def __setitem__(self, key: Any, Value: Any, /) -> None: | ||
return | ||
|
||
|
||
__all__ = [ | ||
"Dummy", | ||
] |