Skip to content

TYP: Add return types to some top-level func #30565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 31, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ def date_range(
name=None,
closed=None,
**kwargs,
):
) -> DatetimeIndex:
"""
Return a fixed frequency DatetimeIndex.

Expand Down Expand Up @@ -1522,7 +1522,7 @@ def bdate_range(
holidays=None,
closed=None,
**kwargs,
):
) -> DatetimeIndex:
"""
Return a fixed frequency DatetimeIndex, with business day as the default
frequency.
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def merge(
copy: bool = True,
indicator: bool = False,
validate=None,
):
) -> "DataFrame":
op = _MergeOperation(
left,
right,
Expand Down Expand Up @@ -183,7 +183,7 @@ def merge_ordered(
fill_method=None,
suffixes=("_x", "_y"),
how: str = "outer",
):
) -> "DataFrame":
"""
Perform merge with optional filling/interpolation.

Expand Down Expand Up @@ -317,7 +317,7 @@ def merge_asof(
tolerance=None,
allow_exact_matches: bool = True,
direction: str = "backward",
):
) -> "DataFrame":
"""
Perform an asof merge. This is similar to a left-join except that we
match on nearest key rather than equal keys.
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/reshape/pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def pivot_table(
dropna=True,
margins_name="All",
observed=False,
):
) -> "DataFrame":
index = _convert_by(index)
columns = _convert_by(columns)

Expand Down Expand Up @@ -148,7 +148,7 @@ def pivot_table(
table = table.sort_index(axis=1)

if fill_value is not None:
table = table.fillna(value=fill_value, downcast="infer")
table: "DataFrame" = table.fillna(value=fill_value, downcast="infer")

if margins:
if dropna:
Expand Down Expand Up @@ -426,7 +426,7 @@ def _convert_by(by):

@Substitution("\ndata : DataFrame")
@Appender(_shared_docs["pivot"], indents=1)
def pivot(data: "DataFrame", index=None, columns=None, values=None):
def pivot(data: "DataFrame", index=None, columns=None, values=None) -> "DataFrame":
if values is None:
cols = [columns] if index is None else [index, columns]
append = index is None
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/json/_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _json_normalize(
errors: Optional[str] = "raise",
sep: str = ".",
max_level: Optional[int] = None,
):
) -> "DataFrame":
"""
Normalize semi-structured JSON data into a flat table.

Expand Down
3 changes: 2 additions & 1 deletion pandas/util/_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"""
import os
import sys
from typing import NoReturn

PKG = os.path.dirname(os.path.dirname(__file__))


def test(extra_args=None):
def test(extra_args=None) -> NoReturn:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we use this pattern elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, but is the correct one because of sys.exit is used here, if I underdtand it correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I see now NoReturn was only added in Python 3.6.2. We support 3.6.1 currently.

I'll remove this annotation unless peope think it's good idea to raise the python minimum version (I don't think it's a good idea myself).

try:
import pytest
except ImportError:
Expand Down