old_contents: from inbox.models import (Calendar, Contact, Message, Event, Block, Message,
                            Tag, Thread)
  
  
  def reconcile_message(new_message, session):
      """
      Check to see if the (synced) Message instance new_message was originally
      created/sent via the Inbox API (based on the X-Inbox-Uid header. If so,
      update the existing message with new attributes from the synced message
      and return it.
  
      """
      if new_message.inbox_uid is None:
          return None
  
      if '-' not in new_message.inbox_uid:
          # Old X-Inbox-Id format; use the old reconciliation strategy.
          existing_message = session.query(Message).filter(
              Message.namespace_id == new_message.namespace_id,
              Message.inbox_uid == new_message.inbox_uid,
              Message.is_created == True).first()
          version = None
      else:
          # new_message has the new X-Inbox-Id format <public_id>-<version>
          # If this is an old version of a current draft, we want to:
          # * not commit a new, separate Message object for it
          # * not update the current draft with the old header values in the code
          #   below.
          expected_public_id, version = new_message.inbox_uid.split('-')
          existing_message = session.query(Message).filter(
              Message.namespace_id == new_message.namespace_id,
              Message.public_id == expected_public_id,
              Message.is_created == True).first()
  
      if existing_message is None:
          return None
  
      if version is None or int(version) == existing_message.version:
          existing_message.message_id_header = new_message.message_id_header
          existing_message.full_body = new_message.full_body
          existing_message.references = new_message.references
  
      return existing_message
  
  
  def transaction_objects():
      """
      Return the mapping from API object name - which becomes the
      Transaction.object_type - for models that generate Transactions (i.e.
      models that implement the HasRevisions mixin).
  
      """
      return {
          'calendar': Calendar,
          'contact': Contact,
          'draft': Message,
          'event': Event,
          'file': Block,
          'message': Message,
          'tag': Tag,
          'thread': Thread
      }
  
new_contents: from inbox.models import (Calendar, Contact, Message, Event, Block, Tag,
                            Thread)
  
  
  def reconcile_message(new_message, session):
      """
      Check to see if the (synced) Message instance new_message was originally
      created/sent via the Inbox API (based on the X-Inbox-Uid header. If so,
      update the existing message with new attributes from the synced message
      and return it.
  
      """
      if new_message.inbox_uid is None:
          return None
  
      if '-' not in new_message.inbox_uid:
          # Old X-Inbox-Id format; use the old reconciliation strategy.
          existing_message = session.query(Message).filter(
              Message.namespace_id == new_message.namespace_id,
              Message.inbox_uid == new_message.inbox_uid,
              Message.is_created == True).first()
          version = None
      else:
          # new_message has the new X-Inbox-Id format <public_id>-<version>
          # If this is an old version of a current draft, we want to:
          # * not commit a new, separate Message object for it
          # * not update the current draft with the old header values in the code
          #   below.
          expected_public_id, version = new_message.inbox_uid.split('-')
          existing_message = session.query(Message).filter(
              Message.namespace_id == new_message.namespace_id,
              Message.public_id == expected_public_id,
              Message.is_created == True).first()
  
      if existing_message is None:
          return None
  
      if version is None or int(version) == existing_message.version:
          existing_message.message_id_header = new_message.message_id_header
          existing_message.full_body = new_message.full_body
          existing_message.references = new_message.references
  
      return existing_message
  
  
  def transaction_objects():
      """
      Return the mapping from API object name - which becomes the
      Transaction.object_type - for models that generate Transactions (i.e.
      models that implement the HasRevisions mixin).
  
      """
      return {
          'calendar': Calendar,
          'contact': Contact,
          'draft': Message,
          'event': Event,
          'file': Block,
          'message': Message,
          'tag': Tag,
          'thread': Thread
      }
  
subject: Remove extraneous import.