# before
from typing import Any, Generator
from expression import Option, Some, effect
def get_result(x: int, y: str) -> Option[list[str]]:
return Some([y, str(x)])
@effect.option[list[str]]()
def fn() -> Generator[Any, Any, list[str]]:
x = yield 42 # in pylance:: (variable) x: Any
y = yield f"{x} as a string" # in pylance:: (variable) x: Any
z = yield from get_result(x, y) # in pylance:: (variable) z: Unknown
return z
fn # in pylance:: (function) fn() -> Option[list[str]]
# after
from typing import Any, Generator
from expression import Option, Some, effect
def get_result(x: int, y: str) -> Option[list[str]]:
return Some([y, str(x)])
@effect.option[list[str]]()
def fn() -> Generator[Any, Any, list[str]]:
x = yield 42 # in pylance:: (variable) x: Any
y = yield f"{x} as a string" # in pylance:: (variable) x: Any
z = yield from get_result(x, y) # in pylance:: (variable) z: list[str]
return z
fn # in pylance:: (function) fn() -> Option[list[str]]
14 Explore better typing for comprehensions / computational expressions
then pylance can analysis Result, Option