Skip to content

Commit 716650a

Browse files
authored
Merge pull request #49 from dimastbk/fix-stubtest
fix(typing): apply mypy.stubtest
2 parents a0b5b30 + 47e0885 commit 716650a

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

python/python_calamine/_python_calamine.pyi

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
from __future__ import annotations
22

3+
import datetime
34
import enum
4-
from datetime import date, datetime, time, timedelta
5-
from os import PathLike
6-
from typing import Protocol
5+
import os
6+
import typing
77

8-
ValueT = int | float | str | bool | time | date | datetime | timedelta
9-
10-
class ReadBuffer(Protocol):
8+
@typing.type_check_only
9+
class ReadBuffer(typing.Protocol):
1110
def seek(self, __offset: int, __whence: int = ...) -> int: ...
1211
def read(self, __size: int = ...) -> bytes | None: ...
1312

13+
@typing.final
1414
class SheetTypeEnum(enum.Enum):
1515
WorkSheet = ...
1616
DialogSheet = ...
1717
MacroSheet = ...
1818
ChartSheet = ...
19-
VBA = ...
19+
Vba = ...
2020

21+
@typing.final
2122
class SheetVisibleEnum(enum.Enum):
2223
Visible = ...
2324
Hidden = ...
2425
VeryHidden = ...
2526

27+
@typing.final
2628
class SheetMetadata:
2729
name: str
2830
typ: SheetTypeEnum
@@ -32,6 +34,7 @@ class SheetMetadata:
3234
self, name: str, typ: SheetTypeEnum, visible: SheetVisibleEnum
3335
) -> None: ...
3436

37+
@typing.final
3538
class CalamineSheet:
3639
name: str
3740
@property
@@ -48,7 +51,18 @@ class CalamineSheet:
4851
def end(self) -> tuple[int, int] | None: ...
4952
def to_python(
5053
self, skip_empty_area: bool = True, nrows: int | None = None
51-
) -> list[list[ValueT]]:
54+
) -> list[
55+
list[
56+
int
57+
| float
58+
| str
59+
| bool
60+
| datetime.time
61+
| datetime.date
62+
| datetime.datetime
63+
| datetime.timedelta
64+
]
65+
]:
5266
"""Retunrning data from sheet as list of lists.
5367
5468
Parameters
@@ -58,13 +72,14 @@ class CalamineSheet:
5872
For suppress this behaviour, set `skip_empty_area` to `False`.
5973
"""
6074

75+
@typing.final
6176
class CalamineWorkbook:
6277
path: str | None
6378
sheet_names: list[str]
6479
sheets_metadata: list[SheetMetadata]
6580
@classmethod
6681
def from_object(
67-
cls, path_or_filelike: str | PathLike | ReadBuffer
82+
cls, path_or_filelike: str | os.PathLike | ReadBuffer
6883
) -> "CalamineWorkbook":
6984
"""Determining type of pyobject and reading from it.
7085
@@ -76,7 +91,7 @@ class CalamineWorkbook:
7691
- IO (must imlpement read/seek methods).
7792
"""
7893
@classmethod
79-
def from_path(cls, path: str | PathLike) -> "CalamineWorkbook":
94+
def from_path(cls, path: str | os.PathLike) -> "CalamineWorkbook":
8095
"""Reading file from path.
8196
8297
Parameters
@@ -96,7 +111,7 @@ class CalamineWorkbook:
96111
class CalamineError(Exception): ...
97112

98113
def load_workbook(
99-
path_or_filelike: str | PathLike | ReadBuffer,
114+
path_or_filelike: str | os.PathLike | ReadBuffer,
100115
) -> CalamineWorkbook:
101116
"""Determining type of pyobject and reading from it.
102117

0 commit comments

Comments
 (0)