From 94923870a9ef160d7f58677d4f646a02847415ea Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Wed, 21 May 2025 14:54:51 -0400 Subject: [PATCH] Use newer TypedDict to allow generic typed dict --- src/obspec/_list.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/obspec/_list.py b/src/obspec/_list.py index 89e501a..fc81021 100644 --- a/src/obspec/_list.py +++ b/src/obspec/_list.py @@ -1,10 +1,18 @@ from __future__ import annotations +import sys from collections.abc import Sequence -from typing import TYPE_CHECKING, Generic, Protocol, TypedDict, TypeVar +from typing import TYPE_CHECKING, Generic, Protocol, TypeVar + +# Note: we need to use the typing-extensions typed dict because we also parametrize over +# a generic +# https://stackoverflow.com/a/79300271 +if sys.version_info >= (3, 11): + from typing import TypedDict +else: + from typing_extensions import TypedDict if TYPE_CHECKING: - import sys from collections.abc import Sequence from ._meta import ObjectMeta