Skip to content

Commit 1a314a0

Browse files
authored
Update enums to reflect typing spec changes (#1020)
* Update enums to reflect typing spec changes See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members python/typing-council#11 The next version of mypy will obey the spec change: python/mypy#18068 pyright already requires this * warning * . * .
1 parent 0de109b commit 1a314a0

File tree

3 files changed

+34
-31
lines changed

3 files changed

+34
-31
lines changed

pandas-stubs/_libs/tslibs/dtypes.pyi

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from enum import Enum
2+
from typing import cast
23

34
from .offsets import BaseOffset
45

@@ -29,16 +30,16 @@ class FreqGroup:
2930
def get_freq_group(code: int) -> int: ...
3031

3132
class Resolution(Enum):
32-
RESO_NS: int
33-
RESO_US: int
34-
RESO_MS: int
35-
RESO_SEC: int
36-
RESO_MIN: int
37-
RESO_HR: int
38-
RESO_DAY: int
39-
RESO_MTH: int
40-
RESO_QTR: int
41-
RESO_YR: int
33+
RESO_NS = cast(int, ...)
34+
RESO_US = cast(int, ...)
35+
RESO_MS = cast(int, ...)
36+
RESO_SEC = cast(int, ...)
37+
RESO_MIN = cast(int, ...)
38+
RESO_HR = cast(int, ...)
39+
RESO_DAY = cast(int, ...)
40+
RESO_MTH = cast(int, ...)
41+
RESO_QTR = cast(int, ...)
42+
RESO_YR = cast(int, ...)
4243

4344
def __lt__(self, other) -> bool: ...
4445
def __ge__(self, other) -> bool: ...

pandas-stubs/core/interchange/dataframe_protocol.pyi

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,34 @@ import enum
1111
from typing import (
1212
Any,
1313
TypedDict,
14+
cast,
1415
)
1516

1617
class DlpackDeviceType(enum.IntEnum):
17-
CPU: int
18-
CUDA: int
19-
CPU_PINNED: int
20-
OPENCL: int
21-
VULKAN: int
22-
METAL: int
23-
VPI: int
24-
ROCM: int
18+
CPU = cast(int, ...)
19+
CUDA = cast(int, ...)
20+
CPU_PINNED = cast(int, ...)
21+
OPENCL = cast(int, ...)
22+
VULKAN = cast(int, ...)
23+
METAL = cast(int, ...)
24+
VPI = cast(int, ...)
25+
ROCM = cast(int, ...)
2526

2627
class DtypeKind(enum.IntEnum):
27-
INT: int
28-
UINT: int
29-
FLOAT: int
30-
BOOL: int
31-
STRING: int
32-
DATETIME: int
33-
CATEGORICAL: int
28+
INT = cast(int, ...)
29+
UINT = cast(int, ...)
30+
FLOAT = cast(int, ...)
31+
BOOL = cast(int, ...)
32+
STRING = cast(int, ...)
33+
DATETIME = cast(int, ...)
34+
CATEGORICAL = cast(int, ...)
3435

3536
class ColumnNullType(enum.IntEnum):
36-
NON_NULLABLE: int
37-
USE_NAN: int
38-
USE_SENTINEL: int
39-
USE_BITMASK: int
40-
USE_BYTEMASK: int
37+
NON_NULLABLE = cast(int, ...)
38+
USE_NAN = cast(int, ...)
39+
USE_SENTINEL = cast(int, ...)
40+
USE_BITMASK = cast(int, ...)
41+
USE_BYTEMASK = cast(int, ...)
4142

4243
class ColumnBuffers(TypedDict):
4344
data: tuple[Buffer, Any]

scripts/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import sys
2+
from typing import Any
23

34
from loguru import logger
45

56
# Config the format of log message
6-
config = {
7+
config: dict[str, Any] = {
78
"handlers": [
89
{
910
"sink": sys.stderr,

0 commit comments

Comments
 (0)