docs: def _detect_encoding(self, source_file):
          """Detect encoding."""
  
          encoding = self._guess(source_file)
          # If we didn't explicitly detect an encoding, assume default.
          if encoding is None:
              encoding = self.default_encoding
  
          return encoding