mypy icon indicating copy to clipboard operation
mypy copied to clipboard

(🎁) Infer local partial type when using `extend` with generator

Open KotlinIsland opened this issue 3 years ago • 0 comments

a = []  # main.py:1: error: Need type annotation for "a" (hint: "a: List[<type>] = ...")
a.extend(a for a in [1])
reveal_type(a)  # main.py:3: note: Revealed type is "builtins.list[Any]"

playground

KotlinIsland avatar Aug 09 '22 05:08 KotlinIsland