From b0ff6c4bd4bdcebeefdd3847d6e032b2db18a4ff Mon Sep 17 00:00:00 2001 From: Patrick Kidger <33688385+patrick-kidger@users.noreply.github.com> Date: Tue, 3 Oct 2023 12:09:44 -0700 Subject: [PATCH] AbstractVar+pyright should now work --- equinox/_better_abstract.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/equinox/_better_abstract.py b/equinox/_better_abstract.py index 447c0ef6..59fe56c5 100644 --- a/equinox/_better_abstract.py +++ b/equinox/_better_abstract.py @@ -8,7 +8,6 @@ import abc import dataclasses from typing import ( - Annotated, ClassVar, Generic, get_args, @@ -23,7 +22,9 @@ if TYPE_CHECKING: - AbstractVar: TypeAlias = Annotated[_T, "AbstractVar"] + # Deliberately confuse pyright into treating this as `Unknown`. + # Then it won't complain when folks override with a concrete variable in a subclass. + AbstractVar: TypeAlias = getattr(abc, "foo" + "bar") # pyright: ignore from typing import ClassVar as AbstractClassVar else: