Skip to content

Commit 1ef1478

Browse files
authored
numpy 1.25.0, pyright 1.1.316, mypy 1.4.1 (#741)
* numpy 1.25.0, pyright 1.1.316, mypy 1.4.1 * avoid specifying python version for mypy
1 parent d23c4bb commit 1ef1478

File tree

3 files changed

+79
-51
lines changed

3 files changed

+79
-51
lines changed

pandas-stubs/_libs/tslibs/timestamps.pyi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ from datetime import (
55
timedelta,
66
tzinfo as _tzinfo,
77
)
8+
import sys
89
from time import struct_time
910
from typing import (
1011
ClassVar,
@@ -45,6 +46,11 @@ _Nonexistent: TypeAlias = (
4546
Literal["raise", "NaT", "shift_backward", "shift_forward"] | Timedelta | timedelta
4647
)
4748

49+
if sys.version_info >= (3, 9):
50+
from datetime import _IsoCalendarDate
51+
else:
52+
_IsoCalendarDate: TypeAlias = tuple[int, int, int]
53+
4854
class Timestamp(datetime):
4955
min: ClassVar[Timestamp]
5056
max: ClassVar[Timestamp]
@@ -227,7 +233,7 @@ class Timestamp(datetime):
227233
def __ne__(self, other: object) -> Literal[True]: ...
228234
def weekday(self) -> int: ...
229235
def isoweekday(self) -> int: ...
230-
def isocalendar(self) -> tuple[int, int, int]: ...
236+
def isocalendar(self) -> _IsoCalendarDate: ...
231237
@property
232238
def is_leap_year(self) -> bool: ...
233239
@property

pyproject.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@ packages = [
3333
[tool.poetry.dependencies]
3434
python = ">=3.8"
3535
types-pytz = ">= 2022.1.1"
36-
numpy = "<=1.24.3"
36+
numpy = [
37+
{version = "<=1.24.3", python = "<=3.8"},
38+
{version = ">=1.25.0", python = ">=3.9"}
39+
]
3740

3841
[tool.poetry.dev-dependencies]
39-
mypy = "1.3.0"
40-
pandas = "2.0.2"
42+
mypy = "1.4.1"
43+
pandas = "2.0.3"
4144
pyarrow = ">=10.0.1"
4245
pytest = ">=7.1.2"
43-
pyright = "<= 1.1.313"
46+
pyright = ">= 1.1.316"
4447
poethepoet = ">=0.16.5"
4548
loguru = ">=0.6.0"
4649
typing-extensions = ">=4.4.0"
@@ -49,7 +52,7 @@ pre-commit = ">=2.19.0"
4952
black = ">=23.3.0"
5053
isort = ">=5.12.0"
5154
openpyxl = ">=3.0.10"
52-
tables = { version = ">=3.7.0" , python = "<4"} # 3.8.0 depends on blosc2 which caps python to <4
55+
tables = { version = ">=3.8.0" , python = "<4"} # 3.8.0 depends on blosc2 which caps python to <4
5356
lxml = ">=4.9.1"
5457
pyreadstat = ">=1.2.0"
5558
xlrd = ">=2.0.1"
@@ -135,8 +138,6 @@ follow_imports = "normal"
135138
follow_imports_for_stubs = false
136139
no_site_packages = false
137140
no_silence_site_packages = false
138-
# Platform configuration
139-
python_version = "3.8"
140141
# Disallow dynamic typing
141142
disallow_any_unimported = false # TODO
142143
disallow_any_expr = false # TODO

tests/test_io.py

Lines changed: 64 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
TYPE_CHECKING_INVALID_USAGE,
5757
WINDOWS,
5858
check,
59+
pytest_warns_bounded,
5960
)
6061

6162
from pandas.io.api import to_pickle
@@ -371,57 +372,77 @@ def test_hdfstore():
371372
assert_type(store.select("df", start=0, stop=1), Union[DataFrame, Series]),
372373
DataFrame,
373374
)
374-
check(
375-
assert_type(store.select("df", where="index>=1"), Union[DataFrame, Series]),
376-
DataFrame,
377-
)
378-
check(
379-
assert_type(
380-
store.select("df", where=Term("index>=1")),
381-
Union[DataFrame, Series],
382-
),
383-
DataFrame,
384-
)
385-
check(
386-
assert_type(
387-
store.select("df", where=[Term("index>=1")]),
388-
Union[DataFrame, Series],
389-
),
390-
DataFrame,
391-
)
392-
check(assert_type(store.get("df"), Union[DataFrame, Series]), DataFrame)
393-
for key in store:
394-
check(assert_type(key, str), str)
395-
check(assert_type(store.close(), None), type(None))
375+
with pytest_warns_bounded(
376+
DeprecationWarning,
377+
match="`alltrue` is deprecated as of NumPy 1.25.0",
378+
lower="1.24.99",
379+
version_str=np.__version__,
380+
):
381+
check(
382+
assert_type(
383+
store.select("df", where="index>=1"), Union[DataFrame, Series]
384+
),
385+
DataFrame,
386+
)
387+
check(
388+
assert_type(
389+
store.select("df", where=Term("index>=1")),
390+
Union[DataFrame, Series],
391+
),
392+
DataFrame,
393+
)
394+
check(
395+
assert_type(
396+
store.select("df", where=[Term("index>=1")]),
397+
Union[DataFrame, Series],
398+
),
399+
DataFrame,
400+
)
401+
check(assert_type(store.get("df"), Union[DataFrame, Series]), DataFrame)
402+
for key in store:
403+
check(assert_type(key, str), str)
404+
check(assert_type(store.close(), None), type(None))
396405

397-
store = HDFStore(path, model="r")
398-
check(
399-
assert_type(read_hdf(store, "df"), Union[DataFrame, Series]),
400-
DataFrame,
401-
)
402-
store.close()
406+
store = HDFStore(path, model="r")
407+
check(
408+
assert_type(read_hdf(store, "df"), Union[DataFrame, Series]),
409+
DataFrame,
410+
)
411+
store.close()
403412

404413

405414
def test_read_hdf_iterator():
406-
with ensure_clean() as path:
407-
check(assert_type(DF.to_hdf(path, "df", format="table"), None), type(None))
408-
ti = read_hdf(path, chunksize=1)
409-
check(assert_type(ti, TableIterator), TableIterator)
410-
ti.close()
415+
with pytest_warns_bounded(
416+
DeprecationWarning,
417+
match="`alltrue` is deprecated as of NumPy 1.25.0",
418+
lower="1.24.99",
419+
version_str=np.__version__,
420+
):
421+
with ensure_clean() as path:
422+
check(assert_type(DF.to_hdf(path, "df", format="table"), None), type(None))
423+
ti = read_hdf(path, chunksize=1)
424+
check(assert_type(ti, TableIterator), TableIterator)
425+
ti.close()
411426

412-
ti = read_hdf(path, "df", iterator=True)
413-
check(assert_type(ti, TableIterator), TableIterator)
414-
for _ in ti:
415-
pass
416-
ti.close()
427+
ti = read_hdf(path, "df", iterator=True)
428+
check(assert_type(ti, TableIterator), TableIterator)
429+
for _ in ti:
430+
pass
431+
ti.close()
417432

418433

419434
def test_hdf_context_manager():
420-
with ensure_clean() as path:
421-
check(assert_type(DF.to_hdf(path, "df", format="table"), None), type(None))
422-
with HDFStore(path, mode="r") as store:
423-
check(assert_type(store.is_open, bool), bool)
424-
check(assert_type(store.get("df"), Union[DataFrame, Series]), DataFrame)
435+
with pytest_warns_bounded(
436+
DeprecationWarning,
437+
match="`alltrue` is deprecated as of NumPy 1.25.0",
438+
lower="1.24.99",
439+
version_str=np.__version__,
440+
):
441+
with ensure_clean() as path:
442+
check(assert_type(DF.to_hdf(path, "df", format="table"), None), type(None))
443+
with HDFStore(path, mode="r") as store:
444+
check(assert_type(store.is_open, bool), bool)
445+
check(assert_type(store.get("df"), Union[DataFrame, Series]), DataFrame)
425446

426447

427448
def test_hdf_series():

0 commit comments

Comments
 (0)