Describe the Bug
Minimal repro:
def process_name(name: str) -> None:
...
def handle_request(name: str | None, use_callback: bool) -> None:
if name is None:
return
# name is narrowed to str here
def callback() -> None:
process_name(name) # FP: str | None not assignable to str
if use_callback:
callback()
It may not always be sound to do this kind of narrowing (esp. if some other closures can attempt to mutate the value of name) so this could be a good thing to warn in strict mode . But by default we might want consider to be more silent to match all other type checkers' behavior.
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
No response
Describe the Bug
Minimal repro:
It may not always be sound to do this kind of narrowing (esp. if some other closures can attempt to mutate the value of
name) so this could be a good thing to warn in strict mode . But by default we might want consider to be more silent to match all other type checkers' behavior.Sandbox Link
No response
(Only applicable for extension issues) IDE Information
No response