diff --git a/pandas-stubs/_libs/tslibs/timestamps.pyi b/pandas-stubs/_libs/tslibs/timestamps.pyi index 1e000513c..d577cd9eb 100644 --- a/pandas-stubs/_libs/tslibs/timestamps.pyi +++ b/pandas-stubs/_libs/tslibs/timestamps.pyi @@ -5,6 +5,7 @@ from datetime import ( timedelta, tzinfo as _tzinfo, ) +import sys from time import struct_time from typing import ( ClassVar, @@ -45,6 +46,11 @@ _Nonexistent: TypeAlias = ( Literal["raise", "NaT", "shift_backward", "shift_forward"] | Timedelta | timedelta ) +if sys.version_info >= (3, 9): + from datetime import _IsoCalendarDate +else: + _IsoCalendarDate: TypeAlias = tuple[int, int, int] + class Timestamp(datetime): min: ClassVar[Timestamp] max: ClassVar[Timestamp] @@ -227,7 +233,7 @@ class Timestamp(datetime): def __ne__(self, other: object) -> Literal[True]: ... def weekday(self) -> int: ... def isoweekday(self) -> int: ... - def isocalendar(self) -> tuple[int, int, int]: ... + def isocalendar(self) -> _IsoCalendarDate: ... @property def is_leap_year(self) -> bool: ... @property diff --git a/pyproject.toml b/pyproject.toml index 6eec09492..c4d577a94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,14 +33,17 @@ packages = [ [tool.poetry.dependencies] python = ">=3.8" types-pytz = ">= 2022.1.1" -numpy = "<=1.24.3" +numpy = [ + {version = "<=1.24.3", python = "<=3.8"}, + {version = ">=1.25.0", python = ">=3.9"} +] [tool.poetry.dev-dependencies] -mypy = "1.3.0" -pandas = "2.0.2" +mypy = "1.4.1" +pandas = "2.0.3" pyarrow = ">=10.0.1" pytest = ">=7.1.2" -pyright = "<= 1.1.313" +pyright = ">= 1.1.316" poethepoet = ">=0.16.5" loguru = ">=0.6.0" typing-extensions = ">=4.4.0" @@ -49,7 +52,7 @@ pre-commit = ">=2.19.0" black = ">=23.3.0" isort = ">=5.12.0" openpyxl = ">=3.0.10" -tables = { version = ">=3.7.0" , python = "<4"} # 3.8.0 depends on blosc2 which caps python to <4 +tables = { version = ">=3.8.0" , python = "<4"} # 3.8.0 depends on blosc2 which caps python to <4 lxml = ">=4.9.1" pyreadstat = ">=1.2.0" xlrd = ">=2.0.1" @@ -135,8 +138,6 @@ follow_imports = "normal" follow_imports_for_stubs = false no_site_packages = false no_silence_site_packages = false -# Platform configuration -python_version = "3.8" # Disallow dynamic typing disallow_any_unimported = false # TODO disallow_any_expr = false # TODO diff --git a/tests/test_io.py b/tests/test_io.py index 92549ac0a..7de860f6f 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -56,6 +56,7 @@ TYPE_CHECKING_INVALID_USAGE, WINDOWS, check, + pytest_warns_bounded, ) from pandas.io.api import to_pickle @@ -371,57 +372,77 @@ def test_hdfstore(): assert_type(store.select("df", start=0, stop=1), Union[DataFrame, Series]), DataFrame, ) - check( - assert_type(store.select("df", where="index>=1"), Union[DataFrame, Series]), - DataFrame, - ) - check( - assert_type( - store.select("df", where=Term("index>=1")), - Union[DataFrame, Series], - ), - DataFrame, - ) - check( - assert_type( - store.select("df", where=[Term("index>=1")]), - Union[DataFrame, Series], - ), - DataFrame, - ) - check(assert_type(store.get("df"), Union[DataFrame, Series]), DataFrame) - for key in store: - check(assert_type(key, str), str) - check(assert_type(store.close(), None), type(None)) + with pytest_warns_bounded( + DeprecationWarning, + match="`alltrue` is deprecated as of NumPy 1.25.0", + lower="1.24.99", + version_str=np.__version__, + ): + check( + assert_type( + store.select("df", where="index>=1"), Union[DataFrame, Series] + ), + DataFrame, + ) + check( + assert_type( + store.select("df", where=Term("index>=1")), + Union[DataFrame, Series], + ), + DataFrame, + ) + check( + assert_type( + store.select("df", where=[Term("index>=1")]), + Union[DataFrame, Series], + ), + DataFrame, + ) + check(assert_type(store.get("df"), Union[DataFrame, Series]), DataFrame) + for key in store: + check(assert_type(key, str), str) + check(assert_type(store.close(), None), type(None)) - store = HDFStore(path, model="r") - check( - assert_type(read_hdf(store, "df"), Union[DataFrame, Series]), - DataFrame, - ) - store.close() + store = HDFStore(path, model="r") + check( + assert_type(read_hdf(store, "df"), Union[DataFrame, Series]), + DataFrame, + ) + store.close() def test_read_hdf_iterator(): - with ensure_clean() as path: - check(assert_type(DF.to_hdf(path, "df", format="table"), None), type(None)) - ti = read_hdf(path, chunksize=1) - check(assert_type(ti, TableIterator), TableIterator) - ti.close() + with pytest_warns_bounded( + DeprecationWarning, + match="`alltrue` is deprecated as of NumPy 1.25.0", + lower="1.24.99", + version_str=np.__version__, + ): + with ensure_clean() as path: + check(assert_type(DF.to_hdf(path, "df", format="table"), None), type(None)) + ti = read_hdf(path, chunksize=1) + check(assert_type(ti, TableIterator), TableIterator) + ti.close() - ti = read_hdf(path, "df", iterator=True) - check(assert_type(ti, TableIterator), TableIterator) - for _ in ti: - pass - ti.close() + ti = read_hdf(path, "df", iterator=True) + check(assert_type(ti, TableIterator), TableIterator) + for _ in ti: + pass + ti.close() def test_hdf_context_manager(): - with ensure_clean() as path: - check(assert_type(DF.to_hdf(path, "df", format="table"), None), type(None)) - with HDFStore(path, mode="r") as store: - check(assert_type(store.is_open, bool), bool) - check(assert_type(store.get("df"), Union[DataFrame, Series]), DataFrame) + with pytest_warns_bounded( + DeprecationWarning, + match="`alltrue` is deprecated as of NumPy 1.25.0", + lower="1.24.99", + version_str=np.__version__, + ): + with ensure_clean() as path: + check(assert_type(DF.to_hdf(path, "df", format="table"), None), type(None)) + with HDFStore(path, mode="r") as store: + check(assert_type(store.is_open, bool), bool) + check(assert_type(store.get("df"), Union[DataFrame, Series]), DataFrame) def test_hdf_series():