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, data)

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

exception github.GithubException.BadCredentialsException(status, data)

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

exception github.GithubException.UnknownObjectException(status, data)

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

exception github.GithubException.BadUserAgentException(status, data)

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, data)

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, expectedType, transformationException)

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, data)

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

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)
Parameters:
  • content – string
  • new_name – string
class github.InputGitAuthor.InputGitAuthor(name, email, date)
Parameters:
  • name – string
  • email – string
  • date – string
class github.InputGitTreeElement.InputGitTreeElement(path, mode, type, content=NotSet, sha=NotSet)
Parameters:
  • path – string
  • mode – string
  • type – string
  • content – string
  • sha – string