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
12 changes: 10 additions & 2 deletions pandas-stubs/core/arrays/integer.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from pandas.core.arrays.masked import BaseMaskedArray

from pandas._libs.missing import NAType
from pandas._typing import (
AnyArrayLike,
np_ndarray_bool,
)

from pandas.core.dtypes.base import ExtensionDtype as ExtensionDtype

Expand All @@ -16,8 +20,12 @@ class _IntegerDtype(ExtensionDtype):
class IntegerArray(BaseMaskedArray):
@property
def dtype(self) -> _IntegerDtype: ...
def __init__(self, values, mask, copy: bool = ...) -> None: ...
def __setitem__(self, key, value) -> None: ...
def __init__(
self,
values: AnyArrayLike,
mask: np_ndarray_bool,
copy: bool = False,
) -> None: ...

class Int8Dtype(_IntegerDtype): ...
class Int16Dtype(_IntegerDtype): ...
Expand Down
16 changes: 10 additions & 6 deletions pandas-stubs/core/arrays/masked.pyi
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
from collections.abc import Iterator
from typing import (
Any,
overload,
)

from pandas.core.arrays import ExtensionArray as ExtensionArray
from pandas.core.series import Series
from typing_extensions import Self

from pandas._typing import (
DtypeArg,
NpDtype,
Scalar,
ScalarIndexer,
SequenceIndexer,
np_1darray,
np_1darray_bool,
npt,
)

Expand All @@ -20,8 +24,8 @@ class BaseMaskedArray(ExtensionArray):
def __getitem__(self, item: ScalarIndexer) -> Any: ...
@overload
def __getitem__(self, item: SequenceIndexer) -> Self: ...
def __iter__(self): ...
def __invert__(self): ...
def __iter__(self) -> Iterator[Any]: ...
def __invert__(self) -> Self: ...
def to_numpy(
self,
dtype: npt.DTypeLike | None = ...,
Expand All @@ -32,9 +36,9 @@ class BaseMaskedArray(ExtensionArray):
def __array__(
self, dtype: NpDtype | None = None, copy: bool | None = None
) -> np_1darray: ...
def __arrow_array__(self, type=...): ...
def isna(self): ...
def __arrow_array__(self, type: DtypeArg | None = None) -> Any: ...
def copy(self) -> Self: ...
def value_counts(self, dropna: bool = True) -> Series[int]: ...
def isna(self) -> np_1darray_bool: ...
@property
def nbytes(self) -> int: ...
def copy(self): ...
def value_counts(self, dropna: bool = True): ...
18 changes: 13 additions & 5 deletions pandas-stubs/core/arrays/string_.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
from typing import Literal
from typing import (
Any,
Literal,
)

from pandas.core.arrays import PandasArray
from pandas.core.series import Series

from pandas._libs.missing import NAType
from pandas._typing import (
AnyArrayLike,
DtypeArg,
)

from pandas.core.dtypes.base import ExtensionDtype

Expand All @@ -12,7 +20,7 @@ class StringDtype(ExtensionDtype):
def na_value(self) -> NAType: ...

class StringArray(PandasArray):
def __init__(self, values, copy: bool = ...) -> None: ...
def __arrow_array__(self, type=...): ...
def __setitem__(self, key, value) -> None: ...
def value_counts(self, dropna: bool = True): ...
def __init__(self, values: AnyArrayLike, copy: bool = False) -> None: ...
def __arrow_array__(self, type: DtypeArg | None = None) -> Any: ...
def __setitem__(self, key: Any, value: Any) -> None: ...
def value_counts(self, dropna: bool = True) -> Series[int]: ...
2 changes: 1 addition & 1 deletion pandas-stubs/io/excel/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class ExcelFile:
storage_options: StorageOptions = ...,
engine_kwargs: dict[str, Any] | None = ...,
) -> None: ...
def __fspath__(self): ...
def __fspath__(self) -> str: ...
@overload
def parse(
self,
Expand Down
31 changes: 28 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,39 @@ ignore = [
# TODO: remove when window is fully typed
"ANN001", "ANN201", "ANN204", "ANN206",
]
"*array*" = [
"*arrays/sparse/*" = [
# TODO: remove when array is fully typed
"ANN001", "ANN201", "ANN204", "ANN206",
]
"*excel/_base.pyi" = [
# TODO: remove when excel/_base.pyi is fully typed
"*arrays/boolean.pyi" = [
# TODO: remove when boolean array is fully typed
"ANN001", "ANN201", "ANN204", "ANN206",
]
"*arrays/categorical.pyi" = [
# TODO: remove when categorical array is fully typed
"ANN001", "ANN201", "ANN204", "ANN206",
]
"*arrays/datetimelike.pyi" = [
# TODO: remove when array is fully typed
"ANN001", "ANN201", "ANN204", "ANN206",
]
"*arrays/datetimes.pyi" = [
# TODO: remove when datetime array is fully typed
"ANN001", "ANN201", "ANN204", "ANN206",
]
"*arrays/interval.pyi" = [
# TODO: remove when interval array is fully typed
"ANN001", "ANN201", "ANN204", "ANN206",
]
"*arrays/period.pyi" = [
# TODO: remove when period array is fully typed
"ANN001", "ANN201", "ANN204", "ANN206",
]
"*arrays/timedeltas.pyi" = [
# TODO: remove when timedelta array is fully typed
"ANN001", "ANN201", "ANN204", "ANN206",
]

"scripts/*" = [
# The following rules are ignored permanently for good reasons
"EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em
Expand Down
13 changes: 13 additions & 0 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import csv
from functools import partial
import io
import os
import pathlib
from pathlib import Path
import sqlite3
Expand Down Expand Up @@ -1156,6 +1157,18 @@ def test_excel_reader() -> None:
check(assert_type(pd.read_excel(ef), pd.DataFrame), pd.DataFrame)


def test_excel_fspath() -> None:
"""Test ExcelFile.__fspath__ type."""
with ensure_clean(".xlsx") as path:
check(assert_type(DF.to_excel(path), None), type(None))
with pd.ExcelFile(
path_or_buffer=path,
engine="openpyxl",
engine_kwargs={"data_only": True},
) as ef:
check(assert_type(os.fspath(ef), str), str)


def test_excel_writer() -> None:
with ensure_clean(".xlsx") as path:
with pd.ExcelWriter(path) as ew:
Expand Down