Use typing_extensions for NotRequired

This commit is contained in:
Oleksandr Shchur 2026-02-20 17:06:04 +00:00
parent 7695bf1442
commit 47be457206
2 changed files with 7 additions and 1 deletions

View file

@ -20,6 +20,7 @@ dependencies = [
"numpy>=1.21,<3",
"einops>=0.7.0,<1",
"scikit-learn>=1.6.0,<2",
"typing_extensions~=4.0",
]
classifiers = [
"Programming Language :: Python :: 3",

View file

@ -5,7 +5,7 @@
import math
from enum import Enum
from typing import TYPE_CHECKING, Any, Iterable, Iterator, Mapping, NotRequired, Sequence, TypeAlias, TypedDict, cast
from typing import TYPE_CHECKING, Any, Iterable, Iterator, Mapping, Sequence, TypeAlias, TypedDict, cast
import numpy as np
import torch
@ -16,6 +16,11 @@ if TYPE_CHECKING:
import datasets
import fev
try:
from typing import NotRequired # Python 3.11+
except ImportError:
from typing_extensions import NotRequired
TensorOrArray: TypeAlias = torch.Tensor | np.ndarray