Skip to content

Commit

Permalink
AbstractVar+pyright should now work
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-kidger committed Oct 3, 2023
1 parent 539a367 commit b0ff6c4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions equinox/_better_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import abc
import dataclasses
from typing import (
Annotated,
ClassVar,
Generic,
get_args,
Expand All @@ -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:

Expand Down

0 comments on commit b0ff6c4

Please sign in to comment.