Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ ci:
autofix_prs: false
repos:
- repo: https://github.com/python/black
rev: 24.1.1
rev: 24.2.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.3.0
hooks:
- id: ruff
args: [
Expand Down
5 changes: 2 additions & 3 deletions pandas-stubs/core/reshape/concat.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ from typing_extensions import Never

from pandas._typing import (
Axis,
AxisColumn,
AxisIndex,
HashableT1,
HashableT2,
Expand Down Expand Up @@ -53,7 +52,7 @@ def concat( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappin
copy: bool = ...,
) -> DataFrame: ...
@overload
def concat(
def concat( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
objs: Iterable[Series | None] | Mapping[HashableT1, Series | None],
*,
axis: AxisIndex = ...,
Expand All @@ -73,7 +72,7 @@ def concat(
| Mapping[HashableT1, Series | DataFrame | None]
),
*,
axis: AxisColumn,
axis: Axis = ...,
join: Literal["inner", "outer"] = ...,
ignore_index: bool = ...,
keys: Iterable[HashableT2] = ...,
Expand Down
12 changes: 10 additions & 2 deletions tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,18 @@ def test_types_concat_none() -> None:
check(
assert_type(pd.concat([None, series, df], axis=1), pd.DataFrame), pd.DataFrame
)
check(assert_type(pd.concat([None, series, df]), pd.DataFrame), pd.DataFrame)

check(assert_type(pd.concat({"a": None, "b": series}), pd.Series), pd.Series)
check(assert_type(pd.concat({"a": None, "b": df}), pd.DataFrame), pd.DataFrame)
check(
assert_type(pd.concat({"a": None, "b": series, "c": df}, axis=1), pd.DataFrame),
pd.DataFrame,
)
check(
assert_type(pd.concat({"a": None, "b": series, "c": df}), pd.DataFrame),
pd.DataFrame,
)

if TYPE_CHECKING_INVALID_USAGE:
# using assert_type as otherwise the second call would not be type-checked
Expand All @@ -77,8 +82,8 @@ def test_types_concat_none() -> None:


def test_types_concat() -> None:
s: pd.Series = pd.Series([0, 1, -10])
s2: pd.Series = pd.Series([7, -5, 10])
Copy link
Member Author

Choose a reason for hiding this comment

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

These two annotations messed mypy in the previous commit. up

s = pd.Series([0, 1, -10])
s2 = pd.Series([7, -5, 10])

check(assert_type(pd.concat([s, s2]), pd.Series), pd.Series)
check(assert_type(pd.concat([s, s2], axis=1), pd.DataFrame), pd.DataFrame)
Expand Down Expand Up @@ -166,6 +171,9 @@ def test_types_concat() -> None:
adict = {"a": df, 2: df2}
check(assert_type(pd.concat(adict), pd.DataFrame), pd.DataFrame)

data: pd.DataFrame | pd.Series = pd.Series()
check(assert_type(pd.concat([pd.DataFrame(), data]), pd.DataFrame), pd.DataFrame)


def test_concat_args() -> None:
df = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
Expand Down