Skip to content

Commit 429ed80

Browse files
authored
Add numpy as a 'runtime' dependency (#696)
* absolute imports * add numpy as a 'runtime' dependency
1 parent 55546cf commit 429ed80

File tree

17 files changed

+74
-99
lines changed

17 files changed

+74
-99
lines changed

pandas-stubs/__init__.pyi

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from . import (
1+
from pandas import (
22
api as api,
33
arrays as arrays,
44
errors as errors,
@@ -8,15 +8,7 @@ from . import (
88
tseries as tseries,
99
util as util,
1010
)
11-
from ._config import (
12-
describe_option as describe_option,
13-
get_option as get_option,
14-
option_context as option_context,
15-
options as options,
16-
reset_option as reset_option,
17-
set_option as set_option,
18-
)
19-
from .core.api import (
11+
from pandas.core.api import (
2012
NA as NA,
2113
ArrowDtype as ArrowDtype,
2214
BooleanDtype as BooleanDtype,
@@ -73,9 +65,9 @@ from .core.api import (
7365
unique as unique,
7466
value_counts as value_counts,
7567
)
76-
from .core.arrays.sparse import SparseDtype as SparseDtype
77-
from .core.computation.api import eval as eval
78-
from .core.reshape.api import (
68+
from pandas.core.arrays.sparse import SparseDtype as SparseDtype
69+
from pandas.core.computation.api import eval as eval
70+
from pandas.core.reshape.api import (
7971
concat as concat,
8072
crosstab as crosstab,
8173
cut as cut,
@@ -91,7 +83,20 @@ from .core.reshape.api import (
9183
qcut as qcut,
9284
wide_to_long as wide_to_long,
9385
)
94-
from .io.api import (
86+
87+
from pandas._config import (
88+
describe_option as describe_option,
89+
get_option as get_option,
90+
option_context as option_context,
91+
options as options,
92+
reset_option as reset_option,
93+
set_option as set_option,
94+
)
95+
96+
from pandas.util._print_versions import show_versions as show_versions
97+
from pandas.util._tester import test as test
98+
99+
from pandas.io.api import (
95100
ExcelFile as ExcelFile,
96101
ExcelWriter as ExcelWriter,
97102
HDFStore as HDFStore,
@@ -117,10 +122,8 @@ from .io.api import (
117122
read_xml as read_xml,
118123
to_pickle as to_pickle,
119124
)
120-
from .io.json import json_normalize as json_normalize
121-
from .tseries import offsets as offsets
122-
from .tseries.api import infer_freq as infer_freq
123-
from .util._print_versions import show_versions as show_versions
124-
from .util._tester import test as test
125+
from pandas.io.json._normalize import json_normalize as json_normalize
126+
from pandas.tseries import offsets as offsets
127+
from pandas.tseries.api import infer_freq as infer_freq
125128

126129
__version__: str

pandas-stubs/_libs/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from .interval import Interval as Interval
2-
from .tslibs import (
1+
from pandas._libs.interval import Interval as Interval
2+
from pandas._libs.tslibs import (
33
NaT as NaT,
44
NaTType as NaTType,
55
OutOfBoundsDatetime as OutOfBoundsDatetime,

pandas-stubs/_libs/tslibs/__init__.pyi

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,20 @@ __all__ = [
1010
"Tick",
1111
"OutOfBoundsDatetime",
1212
]
13-
from pandas._libs.tslibs.np_datetime import (
14-
OutOfBoundsDatetime as OutOfBoundsDatetime,
15-
OutOfBoundsTimedelta as OutOfBoundsTimedelta,
16-
)
17-
18-
from .nattype import (
13+
from pandas._libs.tslibs.nattype import (
1914
NaT,
2015
NaTType,
2116
iNaT,
2217
nat_strings,
2318
)
24-
from .offsets import (
19+
from pandas._libs.tslibs.np_datetime import (
20+
OutOfBoundsDatetime as OutOfBoundsDatetime,
21+
OutOfBoundsTimedelta as OutOfBoundsTimedelta,
22+
)
23+
from pandas._libs.tslibs.offsets import (
2524
BaseOffset,
2625
Tick,
2726
)
28-
from .period import Period
29-
from .timedeltas import Timedelta
30-
from .timestamps import Timestamp
27+
from pandas._libs.tslibs.period import Period
28+
from pandas._libs.tslibs.timedeltas import Timedelta
29+
from pandas._libs.tslibs.timestamps import Timestamp

pandas-stubs/_libs/tslibs/offsets.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ import numpy as np
1616
from pandas.core.indexes.datetimes import DatetimeIndex
1717
from typing_extensions import Self
1818

19+
from pandas._libs.tslibs.timedeltas import Timedelta
1920
from pandas._typing import npt
2021

2122
from pandas.tseries.holiday import AbstractHolidayCalendar
2223

23-
from .timedeltas import Timedelta
24-
2524
_DatetimeT = TypeVar("_DatetimeT", bound=date)
2625
_TimedeltaT = TypeVar("_TimedeltaT", bound=timedelta)
2726

pandas-stubs/_libs/tslibs/period.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ from pandas.core.series import (
2020
from typing_extensions import TypeAlias
2121

2222
from pandas._libs.tslibs import NaTType
23+
from pandas._libs.tslibs.timestamps import Timestamp
2324
from pandas._typing import npt
2425

25-
from .timestamps import Timestamp
26-
2726
class IncompatibleFrequency(ValueError): ...
2827

2928
from pandas._libs.tslibs.offsets import BaseOffset

pandas-stubs/api/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from . import (
1+
from pandas.api import (
22
extensions as extensions,
33
indexers as indexers,
44
types as types,

pandas-stubs/core/arrays/__init__.pyi

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
from .base import (
1+
from pandas.core.arrays.base import (
22
ExtensionArray as ExtensionArray,
33
ExtensionOpsMixin as ExtensionOpsMixin,
44
ExtensionScalarOpsMixin as ExtensionScalarOpsMixin,
55
)
6-
from .boolean import BooleanArray as BooleanArray
7-
from .categorical import Categorical as Categorical
8-
from .datetimes import DatetimeArray as DatetimeArray
9-
from .integer import IntegerArray as IntegerArray
10-
from .interval import IntervalArray as IntervalArray
11-
from .numpy_ import PandasArray as PandasArray
12-
from .period import (
6+
from pandas.core.arrays.boolean import BooleanArray as BooleanArray
7+
from pandas.core.arrays.categorical import Categorical as Categorical
8+
from pandas.core.arrays.datetimes import DatetimeArray as DatetimeArray
9+
from pandas.core.arrays.integer import IntegerArray as IntegerArray
10+
from pandas.core.arrays.interval import IntervalArray as IntervalArray
11+
from pandas.core.arrays.numpy_ import PandasArray as PandasArray
12+
from pandas.core.arrays.period import (
1313
PeriodArray as PeriodArray,
1414
period_array as period_array,
1515
)
16-
from .sparse import SparseArray as SparseArray
17-
from .string_ import StringArray as StringArray
18-
from .timedeltas import TimedeltaArray as TimedeltaArray
16+
from pandas.core.arrays.sparse import SparseArray as SparseArray
17+
from pandas.core.arrays.string_ import StringArray as StringArray
18+
from pandas.core.arrays.timedeltas import TimedeltaArray as TimedeltaArray

pandas-stubs/core/arrays/boolean.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
from typing import ClassVar
22

33
import numpy as np
4+
from pandas.core.arrays.masked import BaseMaskedArray as BaseMaskedArray
45

56
from pandas._libs.missing import NAType
67
from pandas._typing import type_t
78

89
from pandas.core.dtypes.base import ExtensionDtype as ExtensionDtype
910

10-
from .masked import BaseMaskedArray as BaseMaskedArray
11-
1211
class BooleanDtype(ExtensionDtype):
1312
na_value: ClassVar[NAType]
1413
@classmethod

pandas-stubs/core/arrays/integer.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
from pandas.core.arrays.masked import BaseMaskedArray
2+
13
from pandas._libs.missing import NAType
24

35
from pandas.core.dtypes.base import ExtensionDtype as ExtensionDtype
46

5-
from .masked import BaseMaskedArray
6-
77
class _IntegerDtype(ExtensionDtype):
88
base: None
99
@property
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .accessor import (
1+
from pandas.core.arrays.sparse.accessor import (
22
SparseAccessor as SparseAccessor,
33
SparseFrameAccessor as SparseFrameAccessor,
44
)
5-
from .array import SparseArray as SparseArray
6-
from .dtype import SparseDtype as SparseDtype
5+
from pandas.core.arrays.sparse.array import SparseArray as SparseArray
6+
from pandas.core.arrays.sparse.dtype import SparseDtype as SparseDtype

pandas-stubs/core/series.pyi

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ from typing import (
2020
overload,
2121
)
2222

23-
from core.api import (
24-
Int8Dtype as Int8Dtype,
25-
Int16Dtype as Int16Dtype,
26-
Int32Dtype as Int32Dtype,
27-
Int64Dtype as Int64Dtype,
28-
)
2923
from matplotlib.axes import (
3024
Axes as PlotAxes,
3125
SubplotBase,
@@ -36,9 +30,18 @@ from pandas import (
3630
Timedelta,
3731
Timestamp,
3832
)
33+
from pandas.core.api import (
34+
Int8Dtype as Int8Dtype,
35+
Int16Dtype as Int16Dtype,
36+
Int32Dtype as Int32Dtype,
37+
Int64Dtype as Int64Dtype,
38+
)
3939
from pandas.core.arrays.base import ExtensionArray
4040
from pandas.core.arrays.categorical import CategoricalAccessor
4141
from pandas.core.arrays.interval import IntervalArray
42+
from pandas.core.base import IndexOpsMixin
43+
from pandas.core.frame import DataFrame
44+
from pandas.core.generic import NDFrame
4245
from pandas.core.groupby.generic import SeriesGroupBy
4346
from pandas.core.indexers import BaseIndexer
4447
from pandas.core.indexes.accessors import (
@@ -57,7 +60,9 @@ from pandas.core.indexes.timedeltas import TimedeltaIndex
5760
from pandas.core.indexing import (
5861
_AtIndexer,
5962
_iAtIndexer,
63+
_iLocIndexer,
6064
_IndexSliceTuple,
65+
_LocIndexer,
6166
)
6267
from pandas.core.resample import Resampler
6368
from pandas.core.strings import StringMethods
@@ -140,14 +145,6 @@ from pandas.core.dtypes.base import ExtensionDtype
140145

141146
from pandas.plotting import PlotAccessor
142147

143-
from .base import IndexOpsMixin
144-
from .frame import DataFrame
145-
from .generic import NDFrame
146-
from .indexing import (
147-
_iLocIndexer,
148-
_LocIndexer,
149-
)
150-
151148
_bool = bool
152149
_str = str
153150

pandas-stubs/core/window/__init__.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from .ewm import ExponentialMovingWindow as ExponentialMovingWindow
2-
from .expanding import (
1+
from pandas.core.window.ewm import ExponentialMovingWindow as ExponentialMovingWindow
2+
from pandas.core.window.expanding import (
33
Expanding as Expanding,
44
ExpandingGroupby as ExpandingGroupby,
55
)
6-
from .rolling import (
6+
from pandas.core.window.rolling import (
77
Rolling as Rolling,
88
RollingGroupby as RollingGroupby,
99
Window as Window,

pandas-stubs/io/json/__init__.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
from ._json import read_json as read_json
2-
from ._normalize import json_normalize as json_normalize
3-
from ._table_schema import build_table_schema as build_table_schema
1+
from pandas.io.json._json import read_json as read_json
2+
from pandas.io.json._table_schema import build_table_schema as build_table_schema

pandas-stubs/tseries/__init__.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from pandas.tseries import (
2+
frequencies as frequencies,
3+
offsets as offsets,
4+
)

pandas-stubs/util/__init__.pyi

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,3 @@ from pandas.core.util.hashing import (
22
hash_array as hash_array,
33
hash_pandas_object as hash_pandas_object,
44
)
5-
6-
from ._decorators import (
7-
Appender as Appender,
8-
Substitution as Substitution,
9-
cache_readonly as cache_readonly,
10-
)

pandas-stubs/util/_decorators.pyi

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ from collections.abc import (
44
)
55
from typing import Any
66

7-
from pandas._libs.properties import cache_readonly as cache_readonly
8-
from pandas._typing import F
9-
107
def deprecate(
118
name: str,
129
alternative: Callable[..., Any],
@@ -25,19 +22,4 @@ def deprecate_kwarg(
2522
def rewrite_axis_style_signature(
2623
name: str, extra_params: list[tuple[str, Any]]
2724
) -> Callable[..., Any]: ...
28-
29-
class Substitution:
30-
params = ...
31-
def __init__(self, *args, **kwargs) -> None: ...
32-
def __call__(self, func: F) -> F: ...
33-
def update(self, *args, **kwargs) -> None: ...
34-
35-
class Appender:
36-
addendum: str | None
37-
join = ...
38-
def __init__(
39-
self, addendum: str | None, join: str = ..., indents: int = ...
40-
) -> None: ...
41-
def __call__(self, func: F) -> F: ...
42-
4325
def indent(text: str | None, indents: int = ...) -> str: ...

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ packages = [
3333
[tool.poetry.dependencies]
3434
python = ">=3.8"
3535
types-pytz = ">= 2022.1.1"
36+
numpy = ">=1.24.3"
3637

3738
[tool.poetry.dev-dependencies]
3839
mypy = "1.3.0"
@@ -42,7 +43,6 @@ pytest = ">=7.1.2"
4243
pyright = ">= 1.1.306"
4344
poethepoet = ">=0.16.5"
4445
loguru = ">=0.6.0"
45-
numpy = ">=1.24.3"
4646
typing-extensions = ">=4.4.0"
4747
matplotlib = ">=3.5.1"
4848
pre-commit = ">=2.19.0"

0 commit comments

Comments
 (0)