Added a method for getting a user by their id (#1691)

* Added a method for getting a user by their id

* Added get_user_by_id to MainClass stubs

Fixes #1615
This commit is contained in:
Omar Brikaa
2020-11-10 14:52:58 +11:00
committed by GitHub
parent 546f6495b7
commit 4cfc9912c0
4 changed files with 29 additions and 0 deletions
+14
View File
@@ -275,6 +275,20 @@ class Github(object):
self.__requester, headers, data, completed=True
)
def get_user_by_id(self, user_id):
"""
:calls: `GET /user/:id <http://developer.github.com/v3/users>`_
:param user_id: int
:rtype: :class:`github.NamedUser.NamedUser`
"""
assert isinstance(user_id, int), user_id
headers, data = self.__requester.requestJsonAndCheck(
"GET", "/user/" + str(user_id)
)
return github.NamedUser.NamedUser(
self.__requester, headers, data, completed=True
)
def get_users(self, since=github.GithubObject.NotSet):
"""
:calls: `GET /users <http://developer.github.com/v3/users>`_
+1
View File
@@ -83,6 +83,7 @@ class Github:
def get_user(self, login: _NotSetType = ...) -> AuthenticatedUser: ...
@overload
def get_user(self, login: str) -> NamedUser: ...
def get_user_by_id(self, user_id: int) -> NamedUser: ...
def get_users(
self, since: Union[int, _NotSetType] = ...
) -> PaginatedList[NamedUser]: ...