From 62a1d0bdbc4a5767e99987cf361368332392e34f Mon Sep 17 00:00:00 2001 From: Shantanu Jain Date: Tue, 29 Oct 2024 17:31:43 -0700 Subject: [PATCH] Update enums to reflect typing spec changes See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members https://github.com/python/typing-council/issues/11 --- pandas-stubs/_libs/tslibs/dtypes.pyi | 21 +++++----- .../core/interchange/dataframe_protocol.pyi | 41 ++++++++++--------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/pandas-stubs/_libs/tslibs/dtypes.pyi b/pandas-stubs/_libs/tslibs/dtypes.pyi index 786a156bf..7d0a43ab2 100644 --- a/pandas-stubs/_libs/tslibs/dtypes.pyi +++ b/pandas-stubs/_libs/tslibs/dtypes.pyi @@ -1,4 +1,5 @@ from enum import Enum +from typing import cast from .offsets import BaseOffset @@ -29,16 +30,16 @@ class FreqGroup: def get_freq_group(code: int) -> int: ... class Resolution(Enum): - RESO_NS: int - RESO_US: int - RESO_MS: int - RESO_SEC: int - RESO_MIN: int - RESO_HR: int - RESO_DAY: int - RESO_MTH: int - RESO_QTR: int - RESO_YR: int + RESO_NS = cast(int, ...) + RESO_US = cast(int, ...) + RESO_MS = cast(int, ...) + RESO_SEC = cast(int, ...) + RESO_MIN = cast(int, ...) + RESO_HR = cast(int, ...) + RESO_DAY = cast(int, ...) + RESO_MTH = cast(int, ...) + RESO_QTR = cast(int, ...) + RESO_YR = cast(int, ...) def __lt__(self, other) -> bool: ... def __ge__(self, other) -> bool: ... diff --git a/pandas-stubs/core/interchange/dataframe_protocol.pyi b/pandas-stubs/core/interchange/dataframe_protocol.pyi index 8d6052068..f242119f3 100644 --- a/pandas-stubs/core/interchange/dataframe_protocol.pyi +++ b/pandas-stubs/core/interchange/dataframe_protocol.pyi @@ -11,33 +11,34 @@ import enum from typing import ( Any, TypedDict, + cast ) class DlpackDeviceType(enum.IntEnum): - CPU: int - CUDA: int - CPU_PINNED: int - OPENCL: int - VULKAN: int - METAL: int - VPI: int - ROCM: int + CPU = cast(int, ...) + CUDA = cast(int, ...) + CPU_PINNED = cast(int, ...) + OPENCL = cast(int, ...) + VULKAN = cast(int, ...) + METAL = cast(int, ...) + VPI = cast(int, ...) + ROCM = cast(int, ...) class DtypeKind(enum.IntEnum): - INT: int - UINT: int - FLOAT: int - BOOL: int - STRING: int - DATETIME: int - CATEGORICAL: int + INT = cast(int, ...) + UINT = cast(int, ...) + FLOAT = cast(int, ...) + BOOL = cast(int, ...) + STRING = cast(int, ...) + DATETIME = cast(int, ...) + CATEGORICAL = cast(int, ...) class ColumnNullType(enum.IntEnum): - NON_NULLABLE: int - USE_NAN: int - USE_SENTINEL: int - USE_BITMASK: int - USE_BYTEMASK: int + NON_NULLABLE = cast(int, ...) + USE_NAN = cast(int, ...) + USE_SENTINEL = cast(int, ...) + USE_BITMASK = cast(int, ...) + USE_BYTEMASK = cast(int, ...) class ColumnBuffers(TypedDict): data: tuple[Buffer, Any]