Utilities

Logging

github.enable_console_debug_logging()

This function sets up a very simple logging configuration (log everything on standard output) that is useful for troubleshooting.

Error Handling

exception github.GithubException.GithubException(status: int, data: Union[str, Dict[str, Union[str, List[str], List[Dict[str, str]]]]], headers: Optional[Dict[str, str]])

Error handling in PyGithub is done with exceptions. This class is the base of all exceptions raised by PyGithub (but github.GithubException.BadAttributeException).

Some other types of exceptions might be raised by underlying libraries, for example for network-related issues.

status

The status returned by the Github API

data

The (decoded) data returned by the Github API

headers

The headers returned by the Github API

exception github.GithubException.BadCredentialsException(status: int, data: Union[str, Dict[str, Union[str, List[str], List[Dict[str, str]]]]], headers: Optional[Dict[str, str]])

Exception raised in case of bad credentials (when Github API replies with a 401 or 403 HTML status)

exception github.GithubException.UnknownObjectException(status: int, data: Union[str, Dict[str, Union[str, List[str], List[Dict[str, str]]]]], headers: Optional[Dict[str, str]])

Exception raised when a non-existing object is requested (when Github API replies with a 404 HTML status)

exception github.GithubException.BadUserAgentException(status: int, data: Union[str, Dict[str, Union[str, List[str], List[Dict[str, str]]]]], headers: Optional[Dict[str, str]])

Exception raised when request is sent with a bad user agent header (when Github API replies with a 403 bad user agent HTML status)

exception github.GithubException.RateLimitExceededException(status: int, data: Union[str, Dict[str, Union[str, List[str], List[Dict[str, str]]]]], headers: Optional[Dict[str, str]])

Exception raised when the rate limit is exceeded (when Github API replies with a 403 rate limit exceeded HTML status)

exception github.GithubException.BadAttributeException(actualValue: Any, expectedType: Union[Dict[Tuple[Type[str], Type[str]], Type[dict]], Tuple[Type[str], Type[str]], List[Type[dict]], List[Tuple[Type[str], Type[str]]]], transformationException: Optional[Exception])

Exception raised when Github returns an attribute with the wrong type.

actual_value

The value returned by Github

expected_type

The type PyGithub expected

transformation_exception

The exception raised when PyGithub tried to parse the value

exception github.GithubException.TwoFactorException(status: int, data: Union[str, Dict[str, Union[str, List[str], List[Dict[str, str]]]]], headers: Optional[Dict[str, str]])

Exception raised when Github requires a onetime password for two-factor authentication

exception github.GithubException.IncompletableObject(status: int, data: Union[str, Dict[str, Union[str, List[str], List[Dict[str, str]]]]], headers: Optional[Dict[str, str]])

Exception raised when we can not request an object from Github because the data returned did not include a URL

Default argument

github.NotSet is a special value for arguments you don’t want to provide. You should not have to manipulate it directly, because it’s the default value of all parameters accepting it. Just note that it is different from None, which is an allowed value for some parameters.

Input classes

class github.InputFileContent.InputFileContent(content, new_name=NotSet)

This class represents InputFileContents

Parameters:
  • content – string
  • new_name – string
class github.InputGitAuthor.InputGitAuthor(name, email, date=NotSet)

This class represents InputGitAuthors

Parameters:
  • name – string
  • email – string
  • date – string
class github.InputGitTreeElement.InputGitTreeElement(path, mode, type, content=NotSet, sha=NotSet)

This class represents InputGitTreeElements

Parameters:
  • path – string
  • mode – string
  • type – string
  • content – string
  • sha – string or None