Skip to content

Commit

Permalink
fix concat, update mypy, pyright (#890)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Irv authored Mar 16, 2024
1 parent 7dd7b6a commit 4ede926
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
4 changes: 3 additions & 1 deletion pandas-stubs/core/indexes/multi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ class MultiIndex(Index[Any]):
),
) -> Self: ...
@overload
def __getitem__(self, key: int) -> tuple: ...
def __getitem__( # pyright: ignore[reportIncompatibleMethodOverride]
self, key: int
) -> tuple: ...
def take(
self, indices, axis: int = ..., allow_fill: bool = ..., fill_value=..., **kwargs
): ...
Expand Down
46 changes: 44 additions & 2 deletions pandas-stubs/core/reshape/concat.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,48 @@ from pandas._typing import (
HashableT4,
)

@overload
def concat(
objs: Iterable[DataFrame] | Mapping[HashableT1, DataFrame],
*,
axis: Axis = ...,
join: Literal["inner", "outer"] = ...,
ignore_index: bool = ...,
keys: Iterable[HashableT2] = ...,
levels: Sequence[list[HashableT3] | tuple[HashableT3, ...]] = ...,
names: list[HashableT4] = ...,
verify_integrity: bool = ...,
sort: bool = ...,
copy: bool = ...,
) -> DataFrame: ...
@overload
def concat( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
objs: Iterable[Series] | Mapping[HashableT1, Series],
*,
axis: AxisIndex = ...,
join: Literal["inner", "outer"] = ...,
ignore_index: bool = ...,
keys: Iterable[HashableT2] = ...,
levels: Sequence[list[HashableT3] | tuple[HashableT3, ...]] = ...,
names: list[HashableT4] = ...,
verify_integrity: bool = ...,
sort: bool = ...,
copy: bool = ...,
) -> Series: ...
@overload
def concat( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
objs: Iterable[Series | DataFrame] | Mapping[HashableT1, Series | DataFrame],
*,
axis: Axis = ...,
join: Literal["inner", "outer"] = ...,
ignore_index: bool = ...,
keys: Iterable[HashableT2] = ...,
levels: Sequence[list[HashableT3] | tuple[HashableT3, ...]] = ...,
names: list[HashableT4] = ...,
verify_integrity: bool = ...,
sort: bool = ...,
copy: bool = ...,
) -> DataFrame: ...
@overload
def concat(
objs: Iterable[None] | Mapping[HashableT1, None],
Expand All @@ -38,7 +80,7 @@ def concat(
copy: bool = ...,
) -> Never: ...
@overload
def concat( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
def concat( # type: ignore[overload-overlap]
objs: Iterable[DataFrame | None] | Mapping[HashableT1, DataFrame | None],
*,
axis: Axis = ...,
Expand All @@ -52,7 +94,7 @@ def concat( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappin
copy: bool = ...,
) -> DataFrame: ...
@overload
def concat( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
def concat( # type: ignore[overload-overlap]
objs: Iterable[Series | None] | Mapping[HashableT1, Series | None],
*,
axis: AxisIndex = ...,
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ types-pytz = ">= 2022.1.1"
numpy = { version = ">=1.26.0", python = "<3.13" }

[tool.poetry.group.dev.dependencies]
mypy = "1.8.0"
pandas = "2.2.0"
mypy = "1.9.0"
pandas = "2.2.1"
pyarrow = ">=10.0.1"
pytest = ">=7.1.2"
pyright = ">=1.1.350"
pyright = ">=1.1.354"
poethepoet = ">=0.16.5"
loguru = ">=0.6.0"
typing-extensions = ">=4.4.0"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,13 @@ def test_hdf_series():
def test_spss():
if PD_LTE_22:
warning_class = FutureWarning
message = "ChainedAssignmentError: behaviour will change"
message = "Placeholder"
else:
warning_class = pd.errors.ChainedAssignmentError # type: ignore[attr-defined] # pyright: ignore[reportAttributeAccessIssue]
message = "A value is trying to be set on a copy of a DataFrame"

path = Path(CWD, "data", "labelled-num.sav")
with pytest_warns_bounded(warning_class, message):
with pytest_warns_bounded(warning_class, message, "2.3.0"):
check(
assert_type(read_spss(path, convert_categoricals=True), DataFrame),
DataFrame,
Expand Down

0 comments on commit 4ede926

Please sign in to comment.