from typing import List
import re


def _lint_python_cell(file_name: str, code_lines: List[str]) -> List[str]:
    """
    Given the content of a Python code cell, check it for problems we
    want to avoid.

    :param file_name: Name of the notebook this code came from. This is used
        to make error messages more informative.
    :param code_lines: List of strings, where each item in the list is one
        line of Python code.

    :return: A list of strings, where each string represents an error
        found by this check
    """
    errors = []

    # Jupyter notebooks already store literal newlines
    code_str = "".join(code_lines)

    WARNING_FILTER_REGEX = r".*warnings\.filter.*"
    if bool(re.search(WARNING_FILTER_REGEX, code_str)):
        msg = (
            f"Found use of warnings.simplefilter() or warnings.filterwarnings() in {file_name}. "
            "Do not filter out warnings in example notebooks. Try to fix them or "
            "add text explaining why they can be safely ignored."
        )
        errors.append(msg)

    DELAYED_DECORATOR_REGEX = r"@delayed"
    if bool(re.search(DELAYED_DECORATOR_REGEX, code_str)):
        msg = (
            f"Found a use of '@delayed' in {file_name}. "
            "Instead, 'import dask' and then use '@dask.delayed'."
        )
        errors.append(msg)

    return errors