mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
More precise typing for MainClass.get_user() (#1575)
Use typing.overload for MainClass.get_user() since it can return two disparate types. Correct the docstring for it, as well as locking down Sphinx to <3 due to built docs issue and drive-by link correction. Fixes #1550
This commit is contained in:
+1
-1
@@ -257,7 +257,7 @@ class Github(object):
|
||||
"""
|
||||
:calls: `GET /users/:user <http://developer.github.com/v3/users>`_ or `GET /user <http://developer.github.com/v3/users>`_
|
||||
:param login: string
|
||||
:rtype: :class:`github.NamedUser.NamedUser`
|
||||
:rtype: :class:`github.NamedUser.NamedUser` or :class:`github.AuthenticatedUser.AuthenticatedUser`
|
||||
"""
|
||||
assert login is github.GithubObject.NotSet or isinstance(login, str), login
|
||||
if login is github.GithubObject.NotSet:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from datetime import datetime
|
||||
from io import BytesIO
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Union
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Union, overload
|
||||
|
||||
from github.AuthenticatedUser import AuthenticatedUser
|
||||
from github.Commit import Commit
|
||||
@@ -79,9 +79,10 @@ class Github:
|
||||
since: Union[int, _NotSetType] = ...,
|
||||
visibility: Union[str, _NotSetType] = ...,
|
||||
) -> PaginatedList[Repository]: ...
|
||||
def get_user(
|
||||
self, login: Union[str, _NotSetType] = ...
|
||||
) -> Union[AuthenticatedUser, NamedUser]: ...
|
||||
@overload
|
||||
def get_user(self, login: _NotSetType) -> AuthenticatedUser: ...
|
||||
@overload
|
||||
def get_user(self, login: str) -> NamedUser: ...
|
||||
def get_users(
|
||||
self, since: Union[int, _NotSetType] = ...
|
||||
) -> PaginatedList[NamedUser]: ...
|
||||
|
||||
@@ -126,6 +126,7 @@ class ProjectColumn(github.GithubObject.CompletableGithubObject):
|
||||
:param note: string
|
||||
:param content_id: integer
|
||||
:param content_type: string
|
||||
|
||||
:rtype :class:`github.ProjectCard.ProjectCard`:
|
||||
"""
|
||||
if isinstance(note, str):
|
||||
@@ -150,6 +151,7 @@ class ProjectColumn(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
:calls: `POST POST /projects/columns/:column_id/moves <https://developer.github.com/v3/projects/columns/#move-a-project-column>`_
|
||||
:param position: string
|
||||
|
||||
:rtype: bool
|
||||
"""
|
||||
assert isinstance(position, str), position
|
||||
@@ -164,7 +166,7 @@ class ProjectColumn(github.GithubObject.CompletableGithubObject):
|
||||
|
||||
def delete(self):
|
||||
"""
|
||||
:calls: `DELETE /projects/columns/:column_id <https://developer.github.com/v3/projects/columns/#delete-a-project-column`_
|
||||
:calls: `DELETE /projects/columns/:column_id <https://developer.github.com/v3/projects/columns/#delete-a-project-column>`_
|
||||
:rtype: bool
|
||||
"""
|
||||
status, _, _ = self._requester.requestJson(
|
||||
|
||||
@@ -2924,7 +2924,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
|
||||
def get_releases(self):
|
||||
"""
|
||||
:calls: `GET /repos/:owner/:repo/releases <https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository`_
|
||||
:calls: `GET /repos/:owner/:repo/releases <https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository>`_
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.GitRelease.GitRelease`
|
||||
"""
|
||||
return github.PaginatedList.PaginatedList(
|
||||
|
||||
Reference in New Issue
Block a user