
from typing import List  # noqa: F401, pylint: disable=unused-import

import tarfile
import zipfile


def _get_archive_filelist(filename):
    # type: (str) -> List[str]
    names = []  # type: List[str]
    if tarfile.is_tarfile(filename):
        with tarfile.open(filename) as tar_file:
            names = sorted(tar_file.getnames())
    elif zipfile.is_zipfile(filename):
        with zipfile.ZipFile(filename) as zip_file:
            names = sorted(zip_file.namelist())
    else:
        raise Exception("Can not get filenames from '%s'. "
                        "Not a tar or zip file" % filename)
    if "./" in names:
        names.remove("./")
    return names


from typing import List  # noqa: F401, pylint: disable=unused-import

import tarfile
import zipfile


def _get_archive_filelist(filename):
    # type: (str) -> List[str]
    names = []  # type: List[str]
    if tarfile.is_tarfile(filename):
        with tarfile.open(filename) as tar_file:
            names = sorted(tar_file.getnames())
    elif zipfile.is_zipfile(filename):
        with zipfile.ZipFile(filename) as zip_file:
            names = sorted(zip_file.namelist())
    else:
        raise ValueError("Can not get filenames from '{!s}'. "
                         "Not a tar or zip file".format(filename))
    if "./" in names:
        names.remove("./")
    return names

Raise a ValueError from _get_archive_filelist instead of Exception
Raise a ValueError from _get_archive_filelist instead of Exception

Raising the Exception base class is considered bad style, as the more
specialized child classes carry more information about the kind of error that
occurred. And often no-one actually tries to catch the Exception class.

  
  from typing import List  # noqa: F401, pylint: disable=unused-import
  
  import tarfile
  import zipfile
  
  
  def _get_archive_filelist(filename):
      # type: (str) -> List[str]
      names = []  # type: List[str]
      if tarfile.is_tarfile(filename):
          with tarfile.open(filename) as tar_file:
              names = sorted(tar_file.getnames())
      elif zipfile.is_zipfile(filename):
          with zipfile.ZipFile(filename) as zip_file:
              names = sorted(zip_file.namelist())
      else:
-         raise Exception("Can not get filenames from '%s'. "
+         raise ValueError("Can not get filenames from '{!s}'. "
-                         "Not a tar or zip file" % filename)
+                          "Not a tar or zip file".format(filename))
      if "./" in names:
          names.remove("./")
      return names
  
Raise a ValueError from _get_archive_filelist instead of Exception
## Code Before:

from typing import List  # noqa: F401, pylint: disable=unused-import

import tarfile
import zipfile


def _get_archive_filelist(filename):
    # type: (str) -> List[str]
    names = []  # type: List[str]
    if tarfile.is_tarfile(filename):
        with tarfile.open(filename) as tar_file:
            names = sorted(tar_file.getnames())
    elif zipfile.is_zipfile(filename):
        with zipfile.ZipFile(filename) as zip_file:
            names = sorted(zip_file.namelist())
    else:
        raise Exception("Can not get filenames from '%s'. "
                        "Not a tar or zip file" % filename)
    if "./" in names:
        names.remove("./")
    return names

## Instruction:
Raise a ValueError from _get_archive_filelist instead of Exception
## Code After:

from typing import List  # noqa: F401, pylint: disable=unused-import

import tarfile
import zipfile


def _get_archive_filelist(filename):
    # type: (str) -> List[str]
    names = []  # type: List[str]
    if tarfile.is_tarfile(filename):
        with tarfile.open(filename) as tar_file:
            names = sorted(tar_file.getnames())
    elif zipfile.is_zipfile(filename):
        with zipfile.ZipFile(filename) as zip_file:
            names = sorted(zip_file.namelist())
    else:
        raise ValueError("Can not get filenames from '{!s}'. "
                         "Not a tar or zip file".format(filename))
    if "./" in names:
        names.remove("./")
    return names
