From 0c082a29aae0369587d74b4600eeaacb4497d7c4 Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Tue, 31 Oct 2023 15:38:29 +0000 Subject: [PATCH] feat: add `DType` type hint --- src/awkward/_typing.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/awkward/_typing.py b/src/awkward/_typing.py index 6d19dadc73..8a892306d5 100644 --- a/src/awkward/_typing.py +++ b/src/awkward/_typing.py @@ -2,12 +2,14 @@ # ruff: noqa: PLE0604 from __future__ import annotations +import numpy import sys import typing from typing import * # noqa: F403 __all__ = list( { + "ClassVar", "Final", "Self", "final", @@ -27,7 +29,7 @@ AxisMaybeNone = TypeVar("AxisMaybeNone", int, None) # noqa: F405 if sys.version_info < (3, 11): - from typing import Final, SupportsIndex, runtime_checkable + from typing import ClassVar, Final, SupportsIndex, runtime_checkable from typing_extensions import ( Literal, @@ -40,6 +42,7 @@ ) else: from typing import ( + ClassVar, Final, Literal, Protocol, @@ -57,3 +60,5 @@ "str | int | float | bool | None | list | tuple | JSONMapping" ) JSONMapping: TypeAlias = "dict[str, JSONSerializable]" + +DType = TypeVar("DType", bound=numpy.dtype)