old_contents: from collections import namedtuple
  
  Remote = namedtuple('Remote', ('name', 'url'))
  CommitInfo = namedtuple("CommitInfo", ('commit', 'origin', 'remote_repo'))
  
  
  class PRInfo(object):
      def __init__(self, json):
          self.json = json
  
      @property
      def base_sha(self):
          return self.json['base']['sha']
  
      @property
      def head_sha(self):
          return self.json['head']['sha']
  
      @property
      def has_remote_repo(self):
          return self.json['base']['repo']['owner']['login'] != \
                 self.json['head']['repo']['owner']['login']
  
      @property
      def remote_repo(self):
          return Remote(name=self.json['head']['repo']['owner']['login'],
                        url=self.json['head']['repo']['clone_url'])
  
      def to_commit_info(self):
          remote_repo = None
          if self.has_remote_repo:
              remote_repo = self.remote_repo
          return CommitInfo(self.base_sha, self.head_sha, remote_repo)
  
  
  def get_pr_info(requester, reponame, number):
      "Returns the PullRequest as a PRInfo object"
      resp = requester.get(
          'https://api.github.com/repos/%s/pulls/%s' % (reponame, number))
      return PRInfo(resp.json)
  
new_contents: from collections import namedtuple
  
  Remote = namedtuple('Remote', ('name', 'url'))
  CommitInfo = namedtuple("CommitInfo", ('commit', 'origin', 'remote_repo'))
  
  
  class PRInfo(object):
      def __init__(self, json):
          self.json = json
  
      @property
      def base_sha(self):
          return self.json['base']['sha']
  
      @property
      def head_sha(self):
          return self.json['head']['sha']
  
      @property
      def has_remote_repo(self):
          return self.json['base']['repo']['owner']['login'] != \
                 self.json['head']['repo']['owner']['login']
  
      @property
      def remote_repo(self):
          remote = None
          if self.has_remote_repo:
              remote = Remote(name=self.json['head']['repo']['owner']['login'],
                              url=self.json['head']['repo']['clone_url'])
          return remote
  
      def to_commit_info(self):
          return CommitInfo(self.base_sha, self.head_sha, self.remote_repo)
  
  
  def get_pr_info(requester, reponame, number):
      "Returns the PullRequest as a PRInfo object"
      resp = requester.get(
          'https://api.github.com/repos/%s/pulls/%s' % (reponame, number))
      return PRInfo(resp.json)
  
subject: Refactor remote_repo, to return None if there is no remote.