from typing import Optional


def to_int(s: str) -> Optional[int]:
    """
    >>> to_int('foo')
    >>> to_int('4')
    4
    >>> to_int('4.6')
    """
    try:
        return int(s)
    except ValueError:
        return None