Issues

Note

See the official GitHub API v2 documentation for issues.

class github2.issues.Issue(type)[source]

Issue container.

diff_url

URL for diff output associated with this issue.

position

The position of this issue in a list.

state

State of this issue. Can be open or closed.

patch_url

URL for format-patch associated with this issue.

votes

Number of votes for this issue.

body

The full description for this issue.

pull_request_url

URL for the issue’s related pull request.

number

The issue number (unique for project).

updated_at

The date when this issue was last updated.

created_at

The date this issue was created.

labels

Labels associated with this issue.

closed_at

The date this issue was closed.

title

Issue title.

user

The username of the user that created this issue.

class github2.issues.Comment(type)[source]

Comment container.

id

The comment id.

created_at

The date this comment was created.

updated_at

The date when this comment was last updated.

body

The full text of this comment.

user

The username of the user that created this comment.

class github2.issues.Issues(type)[source]

GitHub API issues functionality.

add_label(project, number, label)[source]

Add a label to an issue.

param str project:
 GitHub project
param int number:
 issue number in the GitHub database
param str label:
 label to attach to issue

Warning

Requires authentication

close(project, number)[source]

Close an issue.

param str project:
 GitHub project
param int number:
 issue number in the GitHub database

Warning

Requires authentication

comment(project, number, comment)[source]

Comment on an issue.

param str project:
 GitHub project
param int number:
 issue number in the GitHub database
param str comment:
 comment to attach to issue

Warning

Requires authentication

comments(project, number)[source]

View comments on an issue.

Parameters:project (str) – GitHub project
edit(project, number, title, body)[source]

Edit an existing issue.

New in version 0.3.0.

param str project:
 GitHub project
param int number:
 issue number in the GitHub database
param str title:
 title for issue
param str body:body for issue

Warning

Requires authentication

list(project, state='open')[source]

Get all issues for project with given state.

Parameters:
  • project (str) – GitHub project
  • state (str) – can be either open or closed
list_by_label(project, label)[source]

Get all issues for project with label.

New in version 0.3.0.

Parameters:
  • project (str) – GitHub project
  • label (str) – a string representing a label (e.g., bug)
list_labels(project)[source]

Get all labels for project.

New in version 0.3.0.

Parameters:project (str) – GitHub project
open(project, title, body)[source]

Open up a new issue.

param str project:
 GitHub project
param str title:
 title for issue
param str body:body for issue

Warning

Requires authentication

remove_label(project, number, label)[source]

Remove an existing label from an issue.

param str project:
 GitHub project
param int number:
 issue number in the GitHub database
param str label:
 label to remove from issue

Warning

Requires authentication

reopen(project, number)[source]

Reopen a closed issue.

New in version 0.3.0.

param str project:
 GitHub project
param int number:
 issue number in the GitHub database

Warning

Requires authentication

search(project, term, state='open')[source]

Get all issues for project that match term with given state.

New in version 0.3.0.

Parameters:
  • project (str) – GitHub project
  • term (str) – term to search issues for
  • state (str) – can be either open or closed
show(project, number)[source]

Get all the data for issue by issue-number.

Parameters:
  • project (str) – GitHub project
  • number (int) – issue number in the GitHub database

Examples

List a Projects Issues

>>> github.issues.list("ask/chishop", state="open")
>>> github.issues.list("ask/chishop", state="closed")

Search a Projects Issues

>>> issues = github.issues.search("ask/chishop", "version twice")
>>> issues[0].title
'Upload hangs on attempted second file.'
>>> github.issues.search("ask/chishop", term="authorization",
...                      state="closed")

View an Issue

>>> issue = github.issues.show("ask/chishop", 1)
>>> issue.title
'Should not be able to upload same version twice.'

View Comments on an Issue

>>> comments = github.issues.comments("ask/chishop", 5)
>>> comments[0].body
'Fix merged into /ask branch.'

Open and Close Issues

>>> new_issue = github.issues.open("ask/chishop", title="New bug",
...                                body="This is a test bug")
>>> new_issue.number
2
>>> github.issues.close("ask/chishop", new_issue.number)
>>> github.issues.reopen("ask/chishop", new_issue.number)

List Labels

>>> github.issues.list_labels("ask/chisop")
[u'TODO', u'ask']
>>> github.issues.list_by_label("ask/chishop", "TODO")
[<Issue: Should not be able to upload same version twice.>]

Add and Remove Labels

>>> github.issues.add_label("ask/chishop", 2, "important")
>>> github.issues.remove_label("ask/chishop", 2, "important")

Edit an Issue

>>> github.issues.edit("ask/chishop", 3, title="New title",
...                    body="New body")

Table Of Contents

Previous topic

Teams

Next topic

Pull requests

This Page