Skip to content

Commit 8db3cc4

Browse files
typing of helper functions
1 parent 4ba36b4 commit 8db3cc4

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

doc/source/whatsnew/v1.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ When :class:`Categorical` contains ``np.nan``,
358358
359359
360360
Default dtype of empty :class:`pandas.Series`
361-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
361+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
362362

363363
Initialising an empty :class:`pandas.Series` without specifying a dtype will raise a `DeprecationWarning` now
364364
(:issue:`17261`). The default dtype will change from ``float64`` to ``object`` in future releases so that it is

pandas/core/construction.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
These should not depend on core.internals.
66
"""
7-
from typing import Optional, Sequence, Union, cast
7+
from typing import TYPE_CHECKING, Any, Optional, Sequence, Union, cast
88

99
import numpy as np
1010
import numpy.ma as ma
@@ -44,8 +44,13 @@
4444
)
4545
from pandas.core.dtypes.missing import isna
4646

47+
from pandas._typing import ArrayLike, Dtype
4748
import pandas.core.common as com
4849

50+
if TYPE_CHECKING:
51+
from pandas.core.series import Series
52+
from pandas.core.index import Index
53+
4954

5055
def array(
5156
data: Sequence[object],
@@ -567,8 +572,7 @@ def _try_cast(
567572
return subarr
568573

569574

570-
# see gh-17261
571-
def is_empty_data(data):
575+
def is_empty_data(data: Any) -> bool:
572576
"""
573577
Utility to check if a Series is instantiated with empty data,
574578
which does not contain dtype information.
@@ -589,19 +593,18 @@ def is_empty_data(data):
589593

590594

591595
def create_series_with_explicit_dtype(
592-
data=None,
593-
index=None,
594-
dtype=None,
595-
name=None,
596-
copy=False,
597-
fastpath=False,
598-
dtype_if_empty=object,
599-
):
596+
data: Any = None,
597+
index: Optional[Union[ArrayLike, Index]] = None,
598+
dtype: Optional[Dtype] = None,
599+
name: Optional[str] = None,
600+
copy: bool = False,
601+
fastpath: bool = False,
602+
dtype_if_empty: Dtype = object,
603+
) -> Series:
600604
"""
601605
Helper to pass an explicit dtype when instantiating an empty Series.
602606
603-
This silences a DeprecationWarning described in the GitHub issue
604-
mentioned above.
607+
This silences a DeprecationWarning described in GitHub-17261.
605608
606609
Parameters
607610
----------

0 commit comments

Comments
 (0)