docs: def close(self, block=False, **kwargs):
          '''
          :param block: If True, this function blocks until the remote file has closed.
          :type block: boolean
  
          Attempts to close the file.
  
          .. note:: The remote file cannot be closed until all parts have
             been fully uploaded. An exception will be thrown if this is
             not the case.
          '''
          self.flush(**kwargs)
  
          # Also populates emptyLastPartAllowed
          self._ensure_write_bufsize(**kwargs)
  
          if self._num_uploaded_parts == 0 and self._empty_last_part_allowed:
              # We haven't uploaded any parts in this session.
              # In case no parts have been uploaded at all and region
              # settings allow last empty part upload, try to upload
              # an empty part (otherwise files with 0 parts cannot be closed).
              try:
                  if USING_PYTHON2:
                      self.upload_part('', 1, **kwargs)
                  else:
                      self.upload_part(b'', 1, **kwargs)
              except dxpy.exceptions.InvalidState:
                  pass
  
          if 'report_progress_fn' in kwargs:
              del kwargs['report_progress_fn']
  
          dxpy.api.file_close(self._dxid, **kwargs)
  
          if block:
              self._wait_on_close(**kwargs)