import os
from typing import Optional
_DEFAULT = 'abc'
def _get_value(param: Optional[str]) -> str:
return param or os.getenv("PARAM", _DEFAULT)
For this function, mypy would complain
Incompatible return value type (got "Optional[str]", expected "str")
but I thought this function will never return None. Am I missing something?