Skip to content

Commit 95be077

Browse files
topper-123simonjayhawkins
authored andcommitted
TYP: Add return types to some top-level func (#30565)
1 parent 17d19c4 commit 95be077

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

pandas/core/indexes/datetimes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ def date_range(
13561356
name=None,
13571357
closed=None,
13581358
**kwargs,
1359-
):
1359+
) -> DatetimeIndex:
13601360
"""
13611361
Return a fixed frequency DatetimeIndex.
13621362
@@ -1522,7 +1522,7 @@ def bdate_range(
15221522
holidays=None,
15231523
closed=None,
15241524
**kwargs,
1525-
):
1525+
) -> DatetimeIndex:
15261526
"""
15271527
Return a fixed frequency DatetimeIndex, with business day as the default
15281528
frequency.

pandas/core/reshape/merge.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def merge(
6868
copy: bool = True,
6969
indicator: bool = False,
7070
validate=None,
71-
):
71+
) -> "DataFrame":
7272
op = _MergeOperation(
7373
left,
7474
right,
@@ -183,7 +183,7 @@ def merge_ordered(
183183
fill_method=None,
184184
suffixes=("_x", "_y"),
185185
how: str = "outer",
186-
):
186+
) -> "DataFrame":
187187
"""
188188
Perform merge with optional filling/interpolation.
189189
@@ -317,7 +317,7 @@ def merge_asof(
317317
tolerance=None,
318318
allow_exact_matches: bool = True,
319319
direction: str = "backward",
320-
):
320+
) -> "DataFrame":
321321
"""
322322
Perform an asof merge. This is similar to a left-join except that we
323323
match on nearest key rather than equal keys.

pandas/core/reshape/pivot.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def pivot_table(
3535
dropna=True,
3636
margins_name="All",
3737
observed=False,
38-
):
38+
) -> "DataFrame":
3939
index = _convert_by(index)
4040
columns = _convert_by(columns)
4141

@@ -148,7 +148,9 @@ def pivot_table(
148148
table = table.sort_index(axis=1)
149149

150150
if fill_value is not None:
151-
table = table.fillna(value=fill_value, downcast="infer")
151+
filled = table.fillna(value=fill_value, downcast="infer")
152+
assert filled is not None # needed for mypy
153+
table = filled
152154

153155
if margins:
154156
if dropna:
@@ -426,7 +428,7 @@ def _convert_by(by):
426428

427429
@Substitution("\ndata : DataFrame")
428430
@Appender(_shared_docs["pivot"], indents=1)
429-
def pivot(data: "DataFrame", index=None, columns=None, values=None):
431+
def pivot(data: "DataFrame", index=None, columns=None, values=None) -> "DataFrame":
430432
if values is None:
431433
cols = [columns] if index is None else [index, columns]
432434
append = index is None

pandas/io/json/_normalize.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def _json_normalize(
118118
errors: Optional[str] = "raise",
119119
sep: str = ".",
120120
max_level: Optional[int] = None,
121-
):
121+
) -> "DataFrame":
122122
"""
123123
Normalize semi-structured JSON data into a flat table.
124124

0 commit comments

Comments
 (0)