From e40988c0e89ff7b7bf4699fd202c27c6b4eb1136 Mon Sep 17 00:00:00 2001 From: AsukaMinato Date: Mon, 19 Jun 2023 20:08:35 +0900 Subject: [PATCH 1/5] date_range() now supports a unit keyword "s" , "ms" , "us" , or "ns" --- pandas-stubs/core/indexes/datetimes.pyi | 1 + tests/test_timefuncs.py | 30 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/pandas-stubs/core/indexes/datetimes.pyi b/pandas-stubs/core/indexes/datetimes.pyi index 86d549318..eaf175222 100644 --- a/pandas-stubs/core/indexes/datetimes.pyi +++ b/pandas-stubs/core/indexes/datetimes.pyi @@ -104,6 +104,7 @@ def date_range( normalize: bool = ..., name: Hashable | None = ..., inclusive: IntervalClosedType = ..., + unit: Literal["s", "ms", "us", "ns"] | None = ..., ) -> DatetimeIndex: ... @overload def bdate_range( diff --git a/tests/test_timefuncs.py b/tests/test_timefuncs.py index 20a965545..3fd429eed 100644 --- a/tests/test_timefuncs.py +++ b/tests/test_timefuncs.py @@ -1177,3 +1177,33 @@ def test_weekofmonth_init(): ), pd.offsets.WeekOfMonth, ) + +def test_date_range_unit(): + check( + assert_type( + pd.date_range("1/1/2022", "2/1/2022", unit="s"), + pd.DatetimeIndex, + ), + pd.DatetimeIndex, + ) + check( + assert_type( + pd.date_range("1/1/2022", "2/1/2022", unit="ms"), + pd.DatetimeIndex, + ), + pd.DatetimeIndex, + ) + check( + assert_type( + pd.date_range("1/1/2022", "2/1/2022", unit="us"), + pd.DatetimeIndex, + ), + pd.DatetimeIndex, + ) + check( + assert_type( + pd.date_range("1/1/2022", "2/1/2022", unit="ns"), + pd.DatetimeIndex, + ), + pd.DatetimeIndex, + ) From 0ddd030735b3a7b2665e858de5534fb1e0494482 Mon Sep 17 00:00:00 2001 From: AsukaMinato Date: Mon, 19 Jun 2023 14:10:47 +0000 Subject: [PATCH 2/5] fix problems --- pandas-stubs/core/indexes/datetimes.pyi | 6 ++++-- tests/test_timefuncs.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pandas-stubs/core/indexes/datetimes.pyi b/pandas-stubs/core/indexes/datetimes.pyi index eaf175222..bc4b0b3e4 100644 --- a/pandas-stubs/core/indexes/datetimes.pyi +++ b/pandas-stubs/core/indexes/datetimes.pyi @@ -6,8 +6,10 @@ from datetime import ( timedelta, tzinfo, ) -from typing import overload - +from typing import ( + Literal, + overload, +) import numpy as np from pandas import ( DataFrame, diff --git a/tests/test_timefuncs.py b/tests/test_timefuncs.py index 3fd429eed..34d37ac9f 100644 --- a/tests/test_timefuncs.py +++ b/tests/test_timefuncs.py @@ -1178,6 +1178,7 @@ def test_weekofmonth_init(): pd.offsets.WeekOfMonth, ) + def test_date_range_unit(): check( assert_type( From 3df72551473a7273eb95fc57f406bec0f0e01e7d Mon Sep 17 00:00:00 2001 From: AsukaMinato Date: Mon, 19 Jun 2023 23:56:55 +0900 Subject: [PATCH 3/5] numpy = "<=1.24.3" --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 79e5b342c..abf886e78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ packages = [ [tool.poetry.dependencies] python = ">=3.8" types-pytz = ">= 2022.1.1" -numpy = ">=1.24.3" +numpy = "<=1.24.3" [tool.poetry.dev-dependencies] mypy = "1.3.0" From 2b944f032b34d928e500353b69fa4215210d514c Mon Sep 17 00:00:00 2001 From: AsukaMinato Date: Tue, 20 Jun 2023 00:58:17 +0900 Subject: [PATCH 4/5] pyright = "<= 1.1.313" --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index abf886e78..6eec09492 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ mypy = "1.3.0" pandas = "2.0.2" pyarrow = ">=10.0.1" pytest = ">=7.1.2" -pyright = ">= 1.1.310" +pyright = "<= 1.1.313" poethepoet = ">=0.16.5" loguru = ">=0.6.0" typing-extensions = ">=4.4.0" From c24f6e993f3d6f63a35f670f7174070de768600b Mon Sep 17 00:00:00 2001 From: asukaminato Date: Tue, 20 Jun 2023 02:11:43 +0900 Subject: [PATCH 5/5] black && isort --- pandas-stubs/core/indexes/datetimes.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas-stubs/core/indexes/datetimes.pyi b/pandas-stubs/core/indexes/datetimes.pyi index bc4b0b3e4..615cb098e 100644 --- a/pandas-stubs/core/indexes/datetimes.pyi +++ b/pandas-stubs/core/indexes/datetimes.pyi @@ -10,6 +10,7 @@ from typing import ( Literal, overload, ) + import numpy as np from pandas import ( DataFrame,