Example 1:
from typing import List, Optionaldef myfunc() -> List[Optional[str]]:some_list = [x for x in "abc"]return some_list
Mypy complains on example 1:
Incompatible return value type (got "List[str]", expected "List[Optional[str]]")
However, this example gets no complaint:
Example 2:
def myfunc() -> List[Optional[str]]:some_list = [x for x in "abc"]return list(some_list)
What is the explanation for the inconsistent behavior?