/ doc / examples / Issue.rst
Issue.rst
 1  Issues
 2  ======
 3  
 4  Get issue
 5  ---------
 6  
 7  .. code-block:: python
 8  
 9      >>> repo = g.get_repo("PyGithub/PyGithub")
10      >>> repo.get_issue(number=874)
11  	Issue(title="PyGithub example usage", number=874)
12  	
13  Create comment on issue
14  -----------------------
15  
16  .. code-block:: python
17  
18      >>> repo = g.get_repo("PyGithub/PyGithub")
19      >>> issue = repo.get_issue(number=874)
20      >>> issue.create_comment("Test")
21      	IssueComment(user=NamedUser(login="user"), id=36763078)
22  
23  Create issue
24  ------------
25  
26  .. code-block:: python
27  
28      >>> repo = g.get_repo("PyGithub/PyGithub")
29      >>> repo.create_issue(title="This is a new issue")
30  	Issue(title="This is a new issue", number=XXX)
31  
32  Create issue with body
33  ----------------------
34  
35  .. code-block:: python
36  
37      >>> repo = g.get_repo("PyGithub/PyGithub")
38      >>> repo.create_issue(title="This is a new issue", body="This is the issue body")
39  	Issue(title="This is a new issue", number=XXX)
40  
41  Create issue with labels
42  ------------------------
43  
44  .. code-block:: python
45  
46      >>> repo = g.get_repo("PyGithub/PyGithub")
47      >>> label = repo.get_label("My Label")
48      >>> repo.create_issue(title="This is a new issue", labels=[label])
49  	Issue(title="This is a new issue", number=XXX)
50  
51  Create issue with assignee
52  --------------------------
53  
54  .. code-block:: python
55  
56      >>> repo = g.get_repo("PyGithub/PyGithub")
57      >>> repo.create_issue(title="This is a new issue", assignee="github-username")
58  	Issue(title="This is a new issue", number=XXX)
59  
60  Create issue with milestone
61  ---------------------------
62  
63  .. code-block:: python
64  
65      >>> repo = g.get_repo("PyGithub/PyGithub")
66      >>> milestone = repo.create_milestone("New Issue Milestone")
67      >>> repo.create_issue(title="This is a new issue", milestone=milestone)
68  	Issue(title="This is a new issue", number=XXX)
69  
70  Close all issues
71  -----------------
72  
73  .. code-block:: python
74  
75      >>> repo = g.get_repo("PyGithub/PyGithub")
76      >>> open_issues = repo.get_issues(state='open')
77      >>> for issue in open_issues:
78      ...     issue.edit(state='closed')