from typing import Iterable
from typing import Set
import re


def filter_files(files: Iterable[str], *, snippet_regex: str) -> Set[str]:
  """Only return files that contain the snippet_regex."""
  regex = re.compile(snippet_regex)
  result: Set[str] = set()
  for fp in files:
    with open(fp, 'r') as f:
      if any(re.search(regex, line) for line in f.readlines()):
        result.add(fp)
  return result