Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 25.9.0
rev: 25.11.0
hooks:
- id: black
18 changes: 15 additions & 3 deletions pandas-stubs/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

from pandas import (
api as api,
arrays as arrays,
Expand Down Expand Up @@ -47,7 +49,6 @@ from pandas.core.api import (
UInt16Dtype as UInt16Dtype,
UInt32Dtype as UInt32Dtype,
UInt64Dtype as UInt64Dtype,
array as array,
bdate_range as bdate_range,
date_range as date_range,
factorize as factorize,
Expand Down Expand Up @@ -100,13 +101,11 @@ from pandas.io.api import (
HDFStore as HDFStore,
read_clipboard as read_clipboard,
read_csv as read_csv,
read_excel as read_excel,
read_feather as read_feather,
read_fwf as read_fwf,
read_hdf as read_hdf,
read_html as read_html,
read_json as read_json,
read_orc as read_orc,
read_parquet as read_parquet,
read_pickle as read_pickle,
read_sas as read_sas,
Expand All @@ -118,8 +117,21 @@ from pandas.io.api import (
read_table as read_table,
read_xml as read_xml,
)
from pandas.io.api import (
read_excel as read_excel, # pyright: ignore[reportUnknownVariableType]
)
from pandas.io.api import (
read_orc as read_orc, # pyright: ignore[reportUnknownVariableType]
)
from pandas.io.json._normalize import json_normalize as json_normalize
from pandas.tseries import offsets as offsets
from pandas.tseries.api import infer_freq as infer_freq

if sys.version_info >= (3, 11):
from pandas.core.construction import array as array
else:
from pandas.core.construction import (
array as array, # pyright: ignore[reportUnknownVariableType]
)

__version__: str
4 changes: 1 addition & 3 deletions pandas-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -967,9 +967,7 @@ ListLikeExceptSeriesAndStr: TypeAlias = (
MutableSequence[Any] | np_1darray | tuple[Any, ...] | Index
)
ListLikeU: TypeAlias = Sequence[Any] | np_1darray | Series | Index
ListLikeHashable: TypeAlias = (
MutableSequence[HashableT] | np_1darray | tuple[HashableT, ...] | range
)
ListLikeHashable: TypeAlias = SequenceNotStr[HashableT] | np_1darray | range

class SupportsDType(Protocol[GenericT_co]):
@property
Expand Down
10 changes: 9 additions & 1 deletion pandas-stubs/core/api.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

from pandas.core.algorithms import (
factorize as factorize,
unique as unique,
Expand All @@ -20,7 +22,6 @@ from pandas.core.arrays.integer import (
UInt64Dtype as UInt64Dtype,
)
from pandas.core.arrays.string_ import StringDtype as StringDtype
from pandas.core.construction import array as array
from pandas.core.frame import DataFrame as DataFrame
from pandas.core.groupby import (
Grouper as Grouper,
Expand Down Expand Up @@ -75,3 +76,10 @@ from pandas.core.dtypes.missing import (

from pandas.io.formats.format import set_eng_float_format as set_eng_float_format
from pandas.tseries.offsets import DateOffset as DateOffset

if sys.version_info >= (3, 11):
from pandas.core.construction import array as array
else:
from pandas.core.construction import (
array as array, # pyright: ignore[reportUnknownVariableType]
)
12 changes: 6 additions & 6 deletions pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
@overload
def sort_values(
self,
by: _str | Sequence[_str],
by: _str | SequenceNotStr[_str],
*,
axis: Axis = 0,
ascending: _bool | Sequence[_bool] = ...,
Expand All @@ -1198,7 +1198,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
@overload
def sort_values(
self,
by: _str | Sequence[_str],
by: _str | SequenceNotStr[_str],
*,
axis: Axis = 0,
ascending: _bool | Sequence[_bool] = ...,
Expand Down Expand Up @@ -1405,7 +1405,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
@overload
def groupby( # type: ignore[overload-overlap] # pyright: ignore reportOverlappingOverload
self,
by: MultiIndex | GroupByObjectNonScalar | None = ...,
by: MultiIndex | GroupByObjectNonScalar[Any] | None = ...,
level: IndexLabel | None = ...,
as_index: Literal[True] = True,
sort: _bool = ...,
Expand All @@ -1416,7 +1416,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
@overload
def groupby( # type: ignore[overload-overlap]
self,
by: MultiIndex | GroupByObjectNonScalar | None = ...,
by: MultiIndex | GroupByObjectNonScalar[Any] | None = ...,
level: IndexLabel | None = ...,
as_index: Literal[False] = False,
sort: _bool = ...,
Expand Down Expand Up @@ -1876,7 +1876,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
@overload
def boxplot(
self,
by: Hashable | ListLikeHashable,
by: Hashable | ListLikeHashable[Hashable],
ax: PlotAxes | None = None,
fontsize: float | _str | None = None,
rot: float = 0,
Expand All @@ -1891,7 +1891,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
@overload
def boxplot(
self,
by: Hashable | ListLikeHashable,
by: Hashable | ListLikeHashable[Hashable],
ax: PlotAxes | None = None,
fontsize: float | _str | None = None,
rot: float = 0,
Expand Down
15 changes: 11 additions & 4 deletions pandas-stubs/core/reshape/tile.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import Sequence
from typing import (
Any,
Literal,
overload,
)
Expand Down Expand Up @@ -102,7 +103,7 @@ def cut(
include_lowest: bool = ...,
duplicates: Literal["raise", "drop"] = ...,
ordered: bool = ...,
) -> tuple[Series, IntervalIndex]: ...
) -> tuple[Series, IntervalIndex[Any]]: ...
@overload
def cut(
x: Sequence[float] | np_ndarray_anyint | np_ndarray_float | Index,
Expand Down Expand Up @@ -132,7 +133,9 @@ def cut(
@overload
def cut(
x: Sequence[float] | np_ndarray_anyint | np_ndarray_float | Index,
bins: int | Sequence[float] | Index[int] | Index[float] | IntervalIndex | Series,
bins: (
int | Sequence[float] | Index[int] | Index[float] | IntervalIndex[Any] | Series
),
right: bool = ...,
*,
labels: Literal[False],
Expand Down Expand Up @@ -163,7 +166,9 @@ def cut(
@overload
def cut(
x: Series,
bins: int | Sequence[float] | Index[int] | Index[float] | IntervalIndex | Series,
bins: (
int | Sequence[float] | Index[int] | Index[float] | IntervalIndex[Any] | Series
),
right: bool = ...,
labels: Literal[False] | Sequence[Label] | None = ...,
retbins: Literal[False] = False,
Expand All @@ -175,7 +180,9 @@ def cut(
@overload
def cut(
x: Sequence[float] | np_ndarray_anyint | np_ndarray_float | Index,
bins: int | Sequence[float] | Index[int] | Index[float] | IntervalIndex | Series,
bins: (
int | Sequence[float] | Index[int] | Index[float] | IntervalIndex[Any] | Series
),
right: bool = ...,
labels: Sequence[Label] | None = ...,
retbins: Literal[False] = False,
Expand Down
10 changes: 7 additions & 3 deletions pandas-stubs/io/api.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ from pandas.io.clipboards import read_clipboard as read_clipboard
from pandas.io.excel import (
ExcelFile as ExcelFile,
ExcelWriter as ExcelWriter,
read_excel as read_excel,
)
from pandas.io.excel import (
read_excel as read_excel, # pyright: ignore[reportUnknownVariableType]
)
from pandas.io.feather_format import read_feather as read_feather
from pandas.io.html import read_html as read_html
from pandas.io.json import read_json as read_json
from pandas.io.orc import read_orc as read_orc
from pandas.io.orc import (
read_orc as read_orc, # pyright: ignore[reportUnknownVariableType]
)
from pandas.io.parquet import read_parquet as read_parquet
from pandas.io.parsers import (
from pandas.io.parsers.readers import (
read_csv as read_csv,
read_fwf as read_fwf,
read_table as read_table,
Expand Down
13 changes: 7 additions & 6 deletions pandas-stubs/io/clipboards.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from collections import defaultdict
from collections.abc import (
Callable,
Hashable,
Sequence,
)
import csv
Expand Down Expand Up @@ -33,9 +34,9 @@ def read_clipboard(
dtype_backend: DtypeBackend | _NoDefaultDoNotUse = ...,
delimiter: str | None = ...,
header: int | Sequence[int] | Literal["infer"] | None = ...,
names: ListLikeHashable | None = ...,
names: ListLikeHashable[Hashable] | None = ...,
index_col: int | str | Sequence[str | int] | Literal[False] | None = ...,
usecols: UsecolsArgType = ...,
usecols: UsecolsArgType[Any] = ...,
dtype: DtypeArg | defaultdict[Any, Any] | None = ...,
engine: CSVEngine | None = ...,
converters: dict[int | str, Callable[[str], Any]] = ...,
Expand Down Expand Up @@ -92,9 +93,9 @@ def read_clipboard(
dtype_backend: DtypeBackend | _NoDefaultDoNotUse = ...,
delimiter: str | None = ...,
header: int | Sequence[int] | Literal["infer"] | None = ...,
names: ListLikeHashable | None = ...,
names: ListLikeHashable[Hashable] | None = ...,
index_col: int | str | Sequence[str | int] | Literal[False] | None = ...,
usecols: UsecolsArgType = ...,
usecols: UsecolsArgType[Any] = ...,
dtype: DtypeArg | defaultdict[Any, Any] | None = ...,
engine: CSVEngine | None = ...,
converters: dict[int | str, Callable[[str], Any]] = ...,
Expand Down Expand Up @@ -151,9 +152,9 @@ def read_clipboard(
dtype_backend: DtypeBackend | _NoDefaultDoNotUse = ...,
delimiter: str | None = ...,
header: int | Sequence[int] | Literal["infer"] | None = ...,
names: ListLikeHashable | None = ...,
names: ListLikeHashable[Hashable] | None = ...,
index_col: int | str | Sequence[str | int] | Literal[False] | None = ...,
usecols: UsecolsArgType = ...,
usecols: UsecolsArgType[Any] = ...,
dtype: DtypeArg | defaultdict[Any, Any] | None = ...,
engine: CSVEngine | None = ...,
converters: dict[int | str, Callable[[str], Any]] = ...,
Expand Down
4 changes: 3 additions & 1 deletion pandas-stubs/io/excel/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from pandas.io.excel._base import (
ExcelFile as ExcelFile,
ExcelWriter as ExcelWriter,
read_excel as read_excel,
)
from pandas.io.excel._base import (
read_excel as read_excel, # pyright: ignore[reportUnknownVariableType]
)
29 changes: 16 additions & 13 deletions pandas-stubs/io/excel/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ from typing import (
overload,
)

from odf.opendocument import OpenDocument # pyright: ignore[reportMissingTypeStubs]
from openpyxl.workbook.workbook import Workbook
from pandas.core.frame import DataFrame
import pyxlsb.workbook # pyright: ignore[reportMissingTypeStubs]
Expand All @@ -35,6 +34,10 @@ from pandas._typing import (
WriteExcelBuffer,
)

from odf.opendocument import ( # pyright: ignore[reportMissingTypeStubs] # isort: skip
OpenDocument, # pyright: ignore[reportUnknownVariableType]
)

@overload
def read_excel(
io: (
Expand All @@ -49,9 +52,9 @@ def read_excel(
sheet_name: list[IntStrT],
*,
header: int | Sequence[int] | None = ...,
names: ListLikeHashable | None = ...,
names: ListLikeHashable[Hashable] | None = ...,
index_col: int | Sequence[int] | str | None = ...,
usecols: str | UsecolsArgType = ...,
usecols: str | UsecolsArgType[Any] = ...,
dtype: str | Dtype | Mapping[str, str | Dtype] | None = ...,
engine: ExcelReadEngine | None = ...,
converters: Mapping[int | str, Callable[[Any], Any]] | None = ...,
Expand Down Expand Up @@ -92,9 +95,9 @@ def read_excel(
sheet_name: None,
*,
header: int | Sequence[int] | None = ...,
names: ListLikeHashable | None = ...,
names: ListLikeHashable[Hashable] | None = ...,
index_col: int | Sequence[int] | str | None = ...,
usecols: str | UsecolsArgType = ...,
usecols: str | UsecolsArgType[Any] = ...,
dtype: str | Dtype | Mapping[str, str | Dtype] | None = ...,
engine: ExcelReadEngine | None = ...,
converters: Mapping[int | str, Callable[[Any], Any]] | None = ...,
Expand Down Expand Up @@ -136,9 +139,9 @@ def read_excel( # type: ignore[overload-cannot-match]
sheet_name: list[int | str],
*,
header: int | Sequence[int] | None = ...,
names: ListLikeHashable | None = ...,
names: ListLikeHashable[Hashable] | None = ...,
index_col: int | Sequence[int] | str | None = ...,
usecols: str | UsecolsArgType = ...,
usecols: str | UsecolsArgType[Any] = ...,
dtype: str | Dtype | Mapping[str, str | Dtype] | None = ...,
engine: ExcelReadEngine | None = ...,
converters: Mapping[int | str, Callable[[Any], Any]] | None = ...,
Expand Down Expand Up @@ -179,9 +182,9 @@ def read_excel(
sheet_name: int | str = ...,
*,
header: int | Sequence[int] | None = ...,
names: ListLikeHashable | None = ...,
names: ListLikeHashable[Hashable] | None = ...,
index_col: int | Sequence[int] | str | None = ...,
usecols: str | UsecolsArgType = ...,
usecols: str | UsecolsArgType[Any] = ...,
dtype: str | Dtype | Mapping[str, str | Dtype] | None = ...,
engine: ExcelReadEngine | None = ...,
converters: Mapping[int | str, Callable[[Any], Any]] | None = ...,
Expand Down Expand Up @@ -261,9 +264,9 @@ class ExcelFile:
self,
sheet_name: list[int | str] | None,
header: int | Sequence[int] | None = ...,
names: ListLikeHashable | None = ...,
names: ListLikeHashable[Hashable] | None = ...,
index_col: int | Sequence[int] | None = ...,
usecols: str | UsecolsArgType = ...,
usecols: str | UsecolsArgType[Any] = ...,
converters: dict[int | str, Callable[[Any], Any]] | None = ...,
true_values: Iterable[Hashable] | None = ...,
false_values: Iterable[Hashable] | None = ...,
Expand All @@ -289,9 +292,9 @@ class ExcelFile:
self,
sheet_name: int | str,
header: int | Sequence[int] | None = ...,
names: ListLikeHashable | None = ...,
names: ListLikeHashable[Hashable] | None = ...,
index_col: int | Sequence[int] | None = ...,
usecols: str | UsecolsArgType = ...,
usecols: str | UsecolsArgType[Any] = ...,
converters: dict[int | str, Callable[[Any], Any]] | None = ...,
true_values: Iterable[Hashable] | None = ...,
false_values: Iterable[Hashable] | None = ...,
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/io/html.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ from pandas._typing import (
def read_html(
io: FilePath | ReadBuffer[str],
*,
match: str | Pattern = ...,
match: str | Pattern[str] = ...,
flavor: HTMLFlavors | Sequence[HTMLFlavors] | None = ...,
header: int | Sequence[int] | None = ...,
index_col: int | Sequence[int] | list[HashableT1] | None = ...,
Expand Down
4 changes: 1 addition & 3 deletions pandas-stubs/io/json/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from pandas.io.json._json import (
read_json as read_json,
)
from pandas.io.json._json import read_json as read_json

# below are untyped imports so commented out
# to_json as to_json,; ujson_dumps as ujson_dumps,; ujson_loads as ujson_loads,
Expand Down
5 changes: 4 additions & 1 deletion pandas-stubs/io/orc.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Any

from fsspec.spec import AbstractFileSystem # pyright: ignore[reportMissingTypeStubs]
from pandas import DataFrame
from pyarrow.fs import FileSystem

Expand All @@ -12,6 +11,10 @@ from pandas._typing import (
ReadBuffer,
)

from fsspec.spec import ( # pyright: ignore[reportMissingTypeStubs] # isort: skip
AbstractFileSystem, # pyright: ignore[reportUnknownVariableType]
)

def read_orc(
path: FilePath | ReadBuffer[bytes],
columns: list[HashableT] | None = None,
Expand Down
Loading