You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Run with --strict-optional
from typing import TypeVar, Callable, Optional, List
_T = TypeVar('_T')
def make(typ: Callable[[], _T]) -> _T:
...
def accept(arg: Optional[_T]) -> _T:
...
accept(make(list))
accept(None)
foo = accept(make(list)) # This works
bar: List[str] = accept(make(list)) # Argument 1 to "accept" has incompatible type "List[_T]"; expected "Optional[List[str]]"
Note: The real code has more arguments and an overload that handles the None case but I cut it down to the shortest repro.
Found while playing around with attrs (now in the typeshed) and using
--strict-optional
:Note: The real code has more arguments and an overload that handles the None case but I cut it down to the shortest repro.
The attrs version of this code is:
The text was updated successfully, but these errors were encountered: