Issue

This part of the documentation covers the module which handles Issues and their related objects:

Issue Objects

class github3.issues.issue.Issue(issue, session=None)

The Issue object. It structures and handles the data returned via the Issues section of the GitHub API.

Two issue instances can be checked like so:

i1 == i2
i1 != i2

And is equivalent to:

i1.id == i2.id
i1.id != i2.id
add_labels(*args)

Add labels to this issue.

Parameters:args (str) – (required), names of the labels you wish to add
Returns:list of Labels
assign(login)

Assigns user login to this issue. This is a short cut for issue.edit.

Parameters:login (str) – username of the person to assign this issue to
Returns:bool
assignee = None

User representing the user the issue was assigned to.

body = None

Body (description) of the issue.

body_html = None

HTML formatted body of the issue.

body_text = None

Plain text formatted body of the issue.

close()

Close this issue.

Returns:bool
closed_at = None

datetime object representing when the issue was closed.

closed_by = None

User who closed the issue.

comment(id_num)

Get a single comment by its id.

The catch here is that id is NOT a simple number to obtain. If you were to look at the comments on issue #15 in sigmavirus24/Todo.txt-python, the first comment’s id is 4150787.

Parameters:id_num (int) – (required), comment id, see example above
Returns:IssueComment
comments = None

Number of comments on this issue.

comments_url = None

Comments url (not a template)

create_comment(body)

Create a comment on this issue.

Parameters:body (str) – (required), comment body
Returns:IssueComment
created_at = None

datetime object representing when the issue was created.

edit(title=None, body=None, assignee=None, state=None, milestone=None, labels=None)

Edit this issue.

Parameters:
  • title (str) – Title of the issue
  • body (str) – markdown formatted body (description) of the issue
  • assignee (str) – login name of user the issue should be assigned to
  • state (str) – accepted values: (‘open’, ‘closed’)
  • milestone (int) – the NUMBER (not title) of the milestone to assign this to [1], or 0 to remove the milestone
  • labels (list) – list of labels to apply this to
Returns:

bool

[1]Milestone numbering starts at 1, i.e. the first milestone you create is 1, the second is 2, etc.
events_url = None

Events url (not a template)

classmethod from_json(json)

Return an instance of cls formed from json.

html_url = None

URL to view the issue at GitHub.

id = None

Unique ID for the issue.

is_closed()

Checks if the issue is closed.

Returns:bool
iter_comments(number=-1)

Iterate over the comments on this issue.

Parameters:number (int) – (optional), number of comments to iterate over
Returns:iterator of IssueComment
iter_events(number=-1)

Iterate over events associated with this issue only.

Parameters:number (int) – (optional), number of events to return. Default: -1 returns all events available.
Returns:generator of IssueEvents
labels = None

Returns the list of Labels on this issue.

labels_urlt = None

Labels URL Template. Expand with name

milestone = None

Milestone this issue was assigned to.

number = None

Issue number (e.g. #15)

pull_request = None

Dictionary URLs for the pull request (if they exist)

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

remove_all_labels()

Remove all labels from this issue.

Returns:an empty list if successful
remove_label(name)

Removes label name from this issue.

Parameters:name (str) – (required), name of the label to remove
Returns:bool
reopen()

Re-open a closed issue.

Returns:bool
replace_labels(labels)

Replace all labels on this issue with labels.

Parameters:labels (list) – label names
Returns:bool
repository = None

Returns (‘owner’, ‘repository’) this issue was filed on.

state = None

State of the issue, e.g., open, closed

title = None

Title of the issue.

to_json()

Return the json representing this object.

updated_at = None

datetime object representing the last time the issue was updated.

user = None

User who opened the issue.


class github3.issues.comment.IssueComment(comment, session=None)

The IssueComment object. This structures and handles the comments on issues specifically.

Two comment instances can be checked like so:

c1 == c2
c1 != c2

And is equivalent to:

c1.id == c2.id
c1.id != c2.id

See also: http://developer.github.com/v3/issues/comments/

delete()

Delete this comment.

Returns:bool
edit(body)

Edit this comment.

Parameters:body (str) – (required), new body of the comment, Markdown formatted
Returns:bool
classmethod from_json(json)

Return an instance of cls formed from json.

issue_url = None

Issue url (not a template)

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

to_json()

Return the json representing this object.

user = None

User who made the comment


class github3.issues.event.IssueEvent(event, session=None)

The IssueEvent object. This specifically deals with events described in the Issues>Events section of the GitHub API.

Two event instances can be checked like so:

e1 == e2
e1 != e2

And is equivalent to:

e1.commit_id == e2.commit_id
e1.commit_id != e2.commit_id
actor = None

User that generated the event.

comments = None

Number of comments

commit_id = None

SHA of the commit.

created_at = None

datetime object representing when the event was created.

event = None

The type of event, e.g., closed

classmethod from_json(json)

Return an instance of cls formed from json.

issue = None

Issue where this comment was made.

pull_request = None

Dictionary of links for the pull request

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

to_json()

Return the json representing this object.


class github3.issues.milestone.Milestone(mile, session=None)

The Milestone object. This is a small class to handle information about milestones on repositories and issues.

See also: http://developer.github.com/v3/issues/milestones/

closed_issues = None

The number of closed issues associated with this milestone.

created_at = None

datetime object representing when the milestone was created.

creator = None

User object representing the creator of the milestone.

delete()

Delete this milestone.

Returns:bool
description = None

Description of this milestone.

due_on = None

datetime representing when this milestone is due.

classmethod from_json(json)

Return an instance of cls formed from json.

iter_labels(number=-1)

Iterate over the labels for every issue associated with this milestone.

Parameters:number (int) – (optional), number of labels to return. Default: -1 returns all available labels.
Returns:generator of Labels
number = None

Identifying number associated with milestone.

open_issues = None

Number of issues associated with this milestone which are still open.

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

state = None

State of the milestone, e.g., open or closed.

title = None

Title of the milestone, e.g., 0.2.

to_json()

Return the json representing this object.

update(title=None, state=None, description=None, due_on=None)

Update this milestone.

All parameters are optional, but it makes no sense to omit all of them at once.

Parameters:
  • title (str) – (optional), new title of the milestone
  • state (str) – (optional), (‘open’, ‘closed’)
  • description (str) – (optional)
  • due_on (str) – (optional), ISO 8601 time format: YYYY-MM-DDTHH:MM:SSZ
Returns:

bool

updated_at = None

datetime object representing when the milestone was updated.


class github3.issues.label.Label(label, session=None)

The Label object. Succintly represents a label that exists in a repository.

See also: http://developer.github.com/v3/issues/labels/

color = None

Color of the label, e.g., 626262

delete()

Delete this label.

Returns:bool
classmethod from_json(json)

Return an instance of cls formed from json.

name = None

Name of the label, e.g., ‘bug’

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

to_json()

Return the json representing this object.

update(name, color)

Update this label.

Parameters:
  • name (str) – (required), new name of the label
  • color (str) – (required), color code, e.g., 626262, no leading ‘#’
Returns:

bool

Table Of Contents

Previous topic

GitHub

Next topic

Models

This Page