
import sys
from gh_api import (
    get_milestone_id,
    get_issues_list,
)

if __name__ == "__main__":

    if len(sys.argv) != 2:
        print(__doc__)
        sys.exit(1)

    milestone = sys.argv[1]

    milestone_id = get_milestone_id(
        "jupyter/nbgrader",
        milestone,
        auth=True)

    # this returns both issues and PRs
    issues = get_issues_list(
        "jupyter/nbgrader",
        state='closed',
        milestone=milestone_id,
        auth=True)

    users = set()
    for issue in issues:
        users.add(issue['user']['login'])

    users = {user.lower(): user for user in users}
    print()
    print("The following users have submitted issues and/or PRs:")
    print("-----------------------------------------------------")
    for user in sorted(users.keys()):
        print("- {}".format(users[user]))
    print("-----------------------------------------------------")


import sys
from gh_api import (
    get_milestones,
    get_milestone_id,
    get_issues_list,
)

if __name__ == "__main__":

    if len(sys.argv) < 2:
        milestones = get_milestones("jupyter/nbgrader", auth=True)
    else:
        milestones = sys.argv[1:]

    users = set()
    for milestone in milestones:
        if milestone['title'] == "No action":
            continue

        print("Getting users for {}...".format(milestone['title']))

        # this returns both issues and PRs
        issues = get_issues_list(
            "jupyter/nbgrader",
            state='all',
            milestone=milestone['number'],
            auth=True)

        for issue in issues:
            users.add(issue['user']['login'])

    users = {user.lower(): user for user in users}
    print()
    print("The following users have submitted issues and/or PRs:")
    print("-----------------------------------------------------")
    for user in sorted(users.keys()):
        print("{}".format(users[user]))
    print("-----------------------------------------------------")

Include multiple milestones and open issues in contributor list
Include multiple milestones and open issues in contributor list [ci skip]

  
  import sys
  from gh_api import (
+     get_milestones,
      get_milestone_id,
      get_issues_list,
  )
  
  if __name__ == "__main__":
  
-     if len(sys.argv) != 2:
+     if len(sys.argv) < 2:
+         milestones = get_milestones("jupyter/nbgrader", auth=True)
+     else:
-         print(__doc__)
-         sys.exit(1)
- 
-     milestone = sys.argv[1]
+         milestones = sys.argv[1:]
- 
-     milestone_id = get_milestone_id(
-         "jupyter/nbgrader",
-         milestone,
-         auth=True)
- 
-     # this returns both issues and PRs
-     issues = get_issues_list(
-         "jupyter/nbgrader",
-         state='closed',
-         milestone=milestone_id,
-         auth=True)
  
      users = set()
+     for milestone in milestones:
+         if milestone['title'] == "No action":
+             continue
+ 
+         print("Getting users for {}...".format(milestone['title']))
+ 
+         # this returns both issues and PRs
+         issues = get_issues_list(
+             "jupyter/nbgrader",
+             state='all',
+             milestone=milestone['number'],
+             auth=True)
+ 
-     for issue in issues:
+         for issue in issues:
-         users.add(issue['user']['login'])
+             users.add(issue['user']['login'])
  
      users = {user.lower(): user for user in users}
      print()
      print("The following users have submitted issues and/or PRs:")
      print("-----------------------------------------------------")
      for user in sorted(users.keys()):
-         print("- {}".format(users[user]))
+         print("{}".format(users[user]))
      print("-----------------------------------------------------")
  
Include multiple milestones and open issues in contributor list
## Code Before:

import sys
from gh_api import (
    get_milestone_id,
    get_issues_list,
)

if __name__ == "__main__":

    if len(sys.argv) != 2:
        print(__doc__)
        sys.exit(1)

    milestone = sys.argv[1]

    milestone_id = get_milestone_id(
        "jupyter/nbgrader",
        milestone,
        auth=True)

    # this returns both issues and PRs
    issues = get_issues_list(
        "jupyter/nbgrader",
        state='closed',
        milestone=milestone_id,
        auth=True)

    users = set()
    for issue in issues:
        users.add(issue['user']['login'])

    users = {user.lower(): user for user in users}
    print()
    print("The following users have submitted issues and/or PRs:")
    print("-----------------------------------------------------")
    for user in sorted(users.keys()):
        print("- {}".format(users[user]))
    print("-----------------------------------------------------")

## Instruction:
Include multiple milestones and open issues in contributor list
## Code After:

import sys
from gh_api import (
    get_milestones,
    get_milestone_id,
    get_issues_list,
)

if __name__ == "__main__":

    if len(sys.argv) < 2:
        milestones = get_milestones("jupyter/nbgrader", auth=True)
    else:
        milestones = sys.argv[1:]

    users = set()
    for milestone in milestones:
        if milestone['title'] == "No action":
            continue

        print("Getting users for {}...".format(milestone['title']))

        # this returns both issues and PRs
        issues = get_issues_list(
            "jupyter/nbgrader",
            state='all',
            milestone=milestone['number'],
            auth=True)

        for issue in issues:
            users.add(issue['user']['login'])

    users = {user.lower(): user for user in users}
    print()
    print("The following users have submitted issues and/or PRs:")
    print("-----------------------------------------------------")
    for user in sorted(users.keys()):
        print("{}".format(users[user]))
    print("-----------------------------------------------------")
