code: def _confidence(matches, ext=None):
      
      results = []
      for match in matches:
          con = (0.8 if len(match.extension) > 9 else
                 float("0.{0}".format(len(match.extension))))
          if ext == match.extension:
              con = 0.9
          results.append(
              PureMagicWithConfidence(confidence=con, **match._asdict()))
      return sorted(results, key=lambda x: x.confidence, reverse=True)
docs: Rough confidence based on string length and file extension