Skip to content

Commit

Permalink
Update enums to reflect typing spec changes (#1020)
Browse files Browse the repository at this point in the history
* 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

* .

* .
  • Loading branch information
hauntsaninja authored Oct 30, 2024
1 parent 0de109b commit 1a314a0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
21 changes: 11 additions & 10 deletions pandas-stubs/_libs/tslibs/dtypes.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from enum import Enum
from typing import cast

from .offsets import BaseOffset

Expand Down Expand Up @@ -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: ...
Expand Down
41 changes: 21 additions & 20 deletions pandas-stubs/core/interchange/dataframe_protocol.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import sys
from typing import Any

from loguru import logger

# Config the format of log message
config = {
config: dict[str, Any] = {
"handlers": [
{
"sink": sys.stderr,
Expand Down

0 comments on commit 1a314a0

Please sign in to comment.