mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
Improve type signature for create_from_raw_data (#1503)
Previously you could call it only on Repository or NamedUser. Now you can call it with any GithubObject subclass -- and the type is carried through to the return value.
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
from datetime import datetime
|
||||
from io import BytesIO
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, Union
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Union
|
||||
|
||||
from github.AuthenticatedUser import AuthenticatedUser
|
||||
from github.Commit import Commit
|
||||
from github.ContentFile import ContentFile
|
||||
from github.Event import Event
|
||||
from github.Gist import Gist
|
||||
from github.GithubObject import _NotSetType
|
||||
from github.GithubObject import GithubObject, _NotSetType
|
||||
from github.GitignoreTemplate import GitignoreTemplate
|
||||
from github.HookDescription import HookDescription
|
||||
from github.Installation import Installation
|
||||
@@ -24,6 +24,8 @@ from github.Topic import Topic
|
||||
|
||||
# from urllib3.util.retry import Retry
|
||||
|
||||
TGithubObject = TypeVar('TGithubObject', bound=GithubObject)
|
||||
|
||||
class Github:
|
||||
def __init__(
|
||||
self,
|
||||
@@ -46,11 +48,11 @@ class Github:
|
||||
def __set_per_page(self, value: int) -> None: ...
|
||||
def create_from_raw_data(
|
||||
self,
|
||||
klass: Union[Type[Repository], Type[NamedUser]],
|
||||
klass: Type[TGithubObject],
|
||||
raw_data: Dict[str, Any],
|
||||
headers: Dict[str, Union[str, int]] = ...,
|
||||
) -> Union[Repository, NamedUser]: ...
|
||||
def dump(self, obj: Repository, file: BytesIO, protocol: int = ...) -> None: ...
|
||||
) -> TGithubObject: ...
|
||||
def dump(self, obj: GithubObject, file: BytesIO, protocol: int = ...) -> None: ...
|
||||
def get_emojis(self) -> Dict[str, str]: ...
|
||||
def get_events(self) -> PaginatedList[Event]: ...
|
||||
def get_gist(self, id: str) -> Gist: ...
|
||||
|
||||
Reference in New Issue
Block a user