Re: from __future__ import annotations bug?

2023-06-30 Thread Joseph Garvin via Python-list
Should mention this also affects Protocol[Buzz] On Fri, Jun 30, 2023, 5:35 PM Joseph Garvin wrote: > ``` > from __future__ import annotations > from typing import Generic, TypeVar > > T = TypeVar("T") > class Foo(Generic[T]): ... > class Bar(Foo[Buzz]): ... # NameError here > class Buzz: ... >

from __future__ import annotations bug?

2023-06-30 Thread Joseph Garvin via Python-list
``` from __future__ import annotations from typing import Generic, TypeVar T = TypeVar("T") class Foo(Generic[T]): ... class Bar(Foo[Buzz]): ... # NameError here class Buzz: ... ``` This will error, despite the __future__ import, because cpython is trying to look up Buzz before it's defined,