from typing import List
from typing import Optional
import re


def _find_attribute_docstring(lines: List[str]) -> Optional[str]:
    """
    Find any docstring that is right above an attribute.
    Args:
        lines: the lines of code that may contain a docstring.

    Returns: a docstring (str) or None.

    """
    result = None
    if lines:
        joined_lines = ''.join(lines).strip()
        docstring_pattern = re.compile(
            r'("{3}\s*([\s\S]+)\s*"{3}|'  # 2: docstring content.
            r'\'{3}\s*([\s\S]+)\s*\'{3})'  # 3: docstring content.
            r'$'
        )
        match = docstring_pattern.match(joined_lines)
        if match:
            result = (match.group(2) or match.group(3)).strip()
    return result