The errors generated for the following code are invalid (when using --strict-optional):
fromtypingimportOptional, Callabledeff1(key: Callable[[], str]) ->None: ...
deff2(key: object) ->None: ...
defg(b: Optional[str]) ->None:
ifb:
f1(lambda: b.upper()) # Item "None" of "Optional[str]" has no attribute "upper"z: Callable[[], str] =lambda: b.upper() # Item "None" of "Optional[str]" has no attribute "upper"f2(lambda: b.upper()) # No errorlambda: b.upper() # No error
My hypothesis is that callable type context for lambda somehow affects how type narrowing behaves.
This was reported by @tueda on Gitter.
The errors generated for the following code are invalid (when using
--strict-optional):My hypothesis is that callable type context for lambda somehow affects how type narrowing behaves.
This was reported by @tueda on Gitter.