From 3db307da3315ce1d691d846786b860f40b7f5f60 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Thu, 21 Jul 2022 08:13:43 +0100 Subject: [PATCH 1/5] ENH: Improve fidelity of io stubs Improve accuracy of io stub files --- pandas-stubs/_typing.pyi | 3 ++ pandas-stubs/io/parquet.pyi | 98 ++++++++++++++++++++++++++----------- pandas-stubs/io/pickle.pyi | 21 +++++--- pandas-stubs/io/spss.pyi | 4 +- pandas-stubs/io/xml.pyi | 8 +++ 5 files changed, 97 insertions(+), 37 deletions(-) diff --git a/pandas-stubs/_typing.pyi b/pandas-stubs/_typing.pyi index 4f43cbbc8..ef4b00bed 100644 --- a/pandas-stubs/_typing.pyi +++ b/pandas-stubs/_typing.pyi @@ -67,6 +67,9 @@ class BaseBuffer(Protocol): ... class ReadBuffer(BaseBuffer, Protocol[AnyStr_cov]): ... class WriteBuffer(BaseBuffer, Protocol[AnyStr_cov]): ... +class ReadPickleBuffer(ReadBuffer[bytes], Protocol): + def readline(self) -> AnyStr_cov: ... + FilePath = Union[str, PathLike[str]] Buffer = Union[IO[AnyStr], RawIOBase, BufferedIOBase, TextIOBase, TextIOWrapper, mmap] diff --git a/pandas-stubs/io/parquet.pyi b/pandas-stubs/io/parquet.pyi index 2fcd0851f..1ea64b6b4 100644 --- a/pandas-stubs/io/parquet.pyi +++ b/pandas-stubs/io/parquet.pyi @@ -1,60 +1,102 @@ from __future__ import annotations -from typing import Sequence +from types import ModuleType +from typing import ( + Any, + Literal, + Sequence, +) from pandas.core.frame import DataFrame -from pandas._typing import FilePathOrBuffer +from pandas._typing import ( + FilePath, + FilePathOrBuffer, + ReadBuffer, + StorageOptions, + WriteBuffer, +) -def get_engine(engine: str) -> BaseImpl: ... +_EngineT = Literal["auto", "pyarrow", "fastparquet"] +_CompressionT = Literal["snappy", "gzip", "brotli", "lz4", "zstd"] + +def get_engine(engine: _EngineT) -> BaseImpl: ... class BaseImpl: @staticmethod - def validate_dataframe(df: DataFrame): ... - def write(self, df: DataFrame, path, compression, **kwargs): ... - def read(self, path, columns=..., **kwargs) -> None: ... + def validate_dataframe(df: DataFrame) -> None: ... + def write( + self, + df: DataFrame, + path: FilePath | WriteBuffer[bytes], + compression: _CompressionT | None, + **kwargs: Any, + ): ... + def read( + self, + path: FilePath | ReadBuffer[bytes], + columns: list[str] | None = ..., + **kwargs: Any, + ) -> None: ... class PyArrowImpl(BaseImpl): - api = ... + api: ModuleType = ... def __init__(self) -> None: ... def write( self, df: DataFrame, - path, - compression=..., - coerce_timestamps=..., + path: FilePath | WriteBuffer[bytes], + compression: _CompressionT | None = ..., index: bool | None = ..., - partition_cols=..., + storage_options: StorageOptions = ..., + partition_cols: list[str] | None = ..., + **kwargs, + ): ... + def read( + self, + path: FilePath | ReadBuffer[bytes], + columns: list[str] | None = ..., + use_nullable_dtypes: bool = ..., + storage_options: StorageOptions = ..., **kwargs, ): ... - def read(self, path, columns=..., **kwargs): ... class FastParquetImpl(BaseImpl): - api = ... + api: ModuleType = ... def __init__(self) -> None: ... def write( self, df: DataFrame, - path, - compression=..., - index=..., - partition_cols=..., - **kwargs, + path: FilePath, + compression: _CompressionT | None = ..., + index: bool | None = ..., + partition_cols: list[str] | None = ..., + storage_options: StorageOptions = ..., + **kwargs: Any, + ): ... + def read( + self, + path: FilePath, + columns: list[str] | None = ..., + storage_options: StorageOptions = ..., + **kwargs: Any, ): ... - def read(self, path, columns=..., **kwargs): ... def to_parquet( df: DataFrame, - path, - engine: str = ..., - compression=..., + path: FilePath | WriteBuffer[bytes] | None, + engine: _EngineT = ..., + compression: _CompressionT | None = ..., index: bool | None = ..., - partition_cols=..., - **kwargs, -): ... + storage_options: StorageOptions = ..., + partition_cols: list[str] | None = ..., + **kwargs: Any, +) -> bytes | None: ... def read_parquet( path: FilePathOrBuffer, - engine: str = ..., - columns: Sequence[str] | None = ..., - **kwargs, + engine: _EngineT = ..., + columns: list[str] | None = ..., + storage_options: StorageOptions = ..., + use_nullable_dtypes: bool = ..., + **kwargs: Any, ) -> DataFrame: ... diff --git a/pandas-stubs/io/pickle.pyi b/pandas-stubs/io/pickle.pyi index 232916607..212ae69e0 100644 --- a/pandas-stubs/io/pickle.pyi +++ b/pandas-stubs/io/pickle.pyi @@ -1,16 +1,23 @@ from __future__ import annotations -from typing import Literal +from typing import Any -from pandas._typing import FilePathOrBuffer +from pandas._typing import ( + CompressionOptions, + FilePath, + ReadPickleBuffer, + StorageOptions, + WriteBuffer, +) def to_pickle( - obj, - filepath_or_buffer: FilePathOrBuffer, - compression: str | None = ..., + obj: Any, + filepath_or_buffer: FilePath | WriteBuffer[bytes], + compression: CompressionOptions = ..., protocol: int = ..., + storage_options: StorageOptions = ..., ): ... def read_pickle( - filepath_or_buffer_or_reader: FilePathOrBuffer, - compression: str | Literal["infer", "gzip", "bz2", "zip", "xz"] | None = ..., + filepath_or_buffer_or_reader: FilePath | ReadPickleBuffer, + compression: CompressionOptions = ..., ): ... diff --git a/pandas-stubs/io/spss.pyi b/pandas-stubs/io/spss.pyi index e874c7d76..03af37b88 100644 --- a/pandas-stubs/io/spss.pyi +++ b/pandas-stubs/io/spss.pyi @@ -4,10 +4,10 @@ from typing import Sequence from pandas.core.frame import DataFrame -from pandas._typing import FilePathOrBuffer +from pandas._typing import FilePath def read_spss( - path: FilePathOrBuffer, + path: FilePath, usecols: Sequence[str] | None = ..., convert_categoricals: bool = ..., ) -> DataFrame: ... diff --git a/pandas-stubs/io/xml.pyi b/pandas-stubs/io/xml.pyi index a2c6ff9ae..e5877af83 100644 --- a/pandas-stubs/io/xml.pyi +++ b/pandas-stubs/io/xml.pyi @@ -1,5 +1,6 @@ from __future__ import annotations +import io from typing import Sequence from pandas.core.frame import DataFrame @@ -15,6 +16,13 @@ from pandas._typing import ( XMLParsers, ) +def get_data_from_filepath( + filepath_or_buffer: FilePath | bytes | ReadBuffer[bytes] | ReadBuffer[str], + encoding: str | None, + compression: CompressionOptions, + storage_options: StorageOptions, +) -> str | bytes | ReadBuffer[bytes] | ReadBuffer[str]: ... +def preprocess_data(data) -> io.StringIO | io.BytesIO: ... def read_xml( path_or_buffer: FilePath | ReadBuffer[bytes] | ReadBuffer[str], xpath: str = ..., From a66ac996120f1f63ec6817e55d32b98246303597 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Thu, 21 Jul 2022 08:57:39 +0100 Subject: [PATCH 2/5] ENH: Improve pandas/io --- pandas-stubs/io/date_converters.pyi | 12 ++++++++---- pandas-stubs/io/feather_format.pyi | 22 ++++++++++++++++++---- pandas-stubs/io/gbq.pyi | 11 +++++------ pandas-stubs/io/gcs.pyi | 9 --------- pandas-stubs/io/orc.pyi | 23 +++++++++++++++++++++-- pandas-stubs/io/parquet.pyi | 5 ++--- 6 files changed, 54 insertions(+), 28 deletions(-) delete mode 100644 pandas-stubs/io/gcs.pyi diff --git a/pandas-stubs/io/date_converters.pyi b/pandas-stubs/io/date_converters.pyi index af259f851..08dd983d1 100644 --- a/pandas-stubs/io/date_converters.pyi +++ b/pandas-stubs/io/date_converters.pyi @@ -1,8 +1,12 @@ from __future__ import annotations -def parse_date_time(date_col, time_col): ... -def parse_date_fields(year_col, month_col, day_col): ... +import numpy as np + +from pandas._typing import npt as npt + +def parse_date_time(date_col, time_col) -> npt.NDArray[np.object_]: ... +def parse_date_fields(year_col, month_col, day_col) -> npt.NDArray[np.object_]: ... def parse_all_fields( year_col, month_col, day_col, hour_col, minute_col, second_col -): ... -def generic_parser(parse_func, *cols): ... +) -> npt.NDArray[np.object_]: ... +def generic_parser(parse_func, *cols) -> np.ndarray: ... diff --git a/pandas-stubs/io/feather_format.pyi b/pandas-stubs/io/feather_format.pyi index deab37c8c..f2199e918 100644 --- a/pandas-stubs/io/feather_format.pyi +++ b/pandas-stubs/io/feather_format.pyi @@ -1,13 +1,27 @@ from __future__ import annotations -# from pandas import DataFrame, Int64Index, RangeIndex from typing import Sequence + from pandas.core.frame import DataFrame -from pandas._typing import FilePathOrBuffer +from pandas._typing import ( + FilePath, + HashableT, + ReadBuffer, + StorageOptions, + WriteBuffer, +) -def to_feather(df: DataFrame, path): ... +def to_feather( + df: DataFrame, + path: FilePath | WriteBuffer[bytes], + storage_options: StorageOptions = ..., + **kwargs, +) -> None: ... def read_feather( - p: FilePathOrBuffer, columns: Sequence | None = ..., use_threads: bool = ... + path: FilePath | ReadBuffer[bytes], + columns: list[HashableT] | None = ..., + use_threads: bool = ..., + storage_options: StorageOptions = ..., ): ... diff --git a/pandas-stubs/io/gbq.pyi b/pandas-stubs/io/gbq.pyi index d09a3c958..b5776da14 100644 --- a/pandas-stubs/io/gbq.pyi +++ b/pandas-stubs/io/gbq.pyi @@ -14,10 +14,10 @@ def read_gbq( dialect: str | None = ..., location: str | None = ..., configuration: dict[str, Any] | None = ..., - credentials=..., + # Credentials is a google type, use Any since unavailable + credentials: Any | None = ..., use_bqstorage_api: bool | None = ..., - private_key=..., - verbose=..., + max_results: int | None = ..., progress_bar_type: str | None = ..., ) -> DataFrame: ... def to_gbq( @@ -31,7 +31,6 @@ def to_gbq( table_schema: list[dict[str, str]] | None = ..., location: str | None = ..., progress_bar: bool = ..., - credentials=..., - verbose=..., - private_key=..., + # Credentials is a google type, use Any since unavailable + credentials: Any | None = ..., ) -> None: ... diff --git a/pandas-stubs/io/gcs.pyi b/pandas-stubs/io/gcs.pyi deleted file mode 100644 index 2009fa5ea..000000000 --- a/pandas-stubs/io/gcs.pyi +++ /dev/null @@ -1,9 +0,0 @@ -from __future__ import annotations - -from pandas._typing import FilePathOrBuffer - -gcsfs = ... - -def get_filepath_or_buffer( - filepath_or_buffer: FilePathOrBuffer, encoding=..., compression=..., mode=... -): ... diff --git a/pandas-stubs/io/orc.pyi b/pandas-stubs/io/orc.pyi index d64b396d3..ef5dac735 100644 --- a/pandas-stubs/io/orc.pyi +++ b/pandas-stubs/io/orc.pyi @@ -1,9 +1,28 @@ from __future__ import annotations +from typing import ( + Any, + Literal, +) + from pandas.core.frame import DataFrame -from pandas._typing import FilePathOrBuffer +from pandas._typing import ( + FilePath, + ReadBuffer, + WriteBuffer, +) def read_orc( - path: FilePathOrBuffer, columns: list[str] | None = ..., **kwargs + path: FilePath | ReadBuffer[bytes], + columns: list[str] | None = ..., + **kwargs, ) -> DataFrame: ... +def to_orc( + df: DataFrame, + path: FilePath | WriteBuffer[bytes] = ..., + *, + engine: Literal["pyarrow"] = ..., + index: bool | None = ..., + engine_kwargs: dict[str, Any] | None = ..., +) -> bytes | None: ... diff --git a/pandas-stubs/io/parquet.pyi b/pandas-stubs/io/parquet.pyi index 1ea64b6b4..f556269e8 100644 --- a/pandas-stubs/io/parquet.pyi +++ b/pandas-stubs/io/parquet.pyi @@ -4,7 +4,6 @@ from types import ModuleType from typing import ( Any, Literal, - Sequence, ) from pandas.core.frame import DataFrame @@ -67,7 +66,7 @@ class FastParquetImpl(BaseImpl): def write( self, df: DataFrame, - path: FilePath, + path: FilePath | WriteBuffer[bytes], compression: _CompressionT | None = ..., index: bool | None = ..., partition_cols: list[str] | None = ..., @@ -76,7 +75,7 @@ class FastParquetImpl(BaseImpl): ): ... def read( self, - path: FilePath, + path: FilePath | WriteBuffer[bytes], columns: list[str] | None = ..., storage_options: StorageOptions = ..., **kwargs: Any, From 118c974188ce8b93653711f84883128d54439cb1 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Thu, 21 Jul 2022 13:44:07 +0100 Subject: [PATCH 3/5] ENH: More improvements for IO --- pandas-stubs/_typing.pyi | 9 +- pandas-stubs/io/clipboard/__init__.pyi | 5 - pandas-stubs/io/clipboards.pyi | 8 +- pandas-stubs/io/common.pyi | 174 +++++++++++++++++++------ pandas-stubs/io/feather_format.pyi | 3 - pandas-stubs/io/html.pyi | 48 ++++--- 6 files changed, 177 insertions(+), 70 deletions(-) diff --git a/pandas-stubs/_typing.pyi b/pandas-stubs/_typing.pyi index ef4b00bed..ab4a9e21f 100644 --- a/pandas-stubs/_typing.pyi +++ b/pandas-stubs/_typing.pyi @@ -63,7 +63,14 @@ DtypeObj = Union[np.dtype[np.generic], ExtensionDtype] AnyStr_cov = TypeVar("AnyStr_cov", str, bytes, covariant=True) AnyStr_con = TypeVar("AnyStr_con", str, bytes, contravariant=True) -class BaseBuffer(Protocol): ... +class BaseBuffer(Protocol): + @property + def mode(self) -> str: ... + def fileno(self) -> int: ... + def seek(self, __offset: int, __whence: int = ...) -> int: ... + def seekable(self) -> bool: ... + def tell(self) -> int: ... + class ReadBuffer(BaseBuffer, Protocol[AnyStr_cov]): ... class WriteBuffer(BaseBuffer, Protocol[AnyStr_cov]): ... diff --git a/pandas-stubs/io/clipboard/__init__.pyi b/pandas-stubs/io/clipboard/__init__.pyi index d8734b46f..86c2ddcf7 100644 --- a/pandas-stubs/io/clipboard/__init__.pyi +++ b/pandas-stubs/io/clipboard/__init__.pyi @@ -1,10 +1,5 @@ from __future__ import annotations -class PyperclipException(RuntimeError): ... - -class PyperclipWindowsException(PyperclipException): - def __init__(self, message) -> None: ... - class CheckedCall: def __init__(self, f) -> None: ... def __call__(self, *args): ... diff --git a/pandas-stubs/io/clipboards.pyi b/pandas-stubs/io/clipboards.pyi index 4cf04c28f..6ceeb128a 100644 --- a/pandas-stubs/io/clipboards.pyi +++ b/pandas-stubs/io/clipboards.pyi @@ -1,6 +1,8 @@ from __future__ import annotations -from pandas.core.frame import DataFrame +from typing import Any -def read_clipboard(sep: str = ..., **kwargs) -> DataFrame: ... -def to_clipboard(obj, excel: bool = ..., sep=..., **kwargs) -> None: ... +def read_clipboard(sep: str = ..., **kwargs): ... +def to_clipboard( + obj, excel: bool | None = ..., sep: str | None = ..., **kwargs: Any +) -> None: ... diff --git a/pandas-stubs/io/common.pyi b/pandas-stubs/io/common.pyi index edb6ca900..51f705720 100644 --- a/pandas-stubs/io/common.pyi +++ b/pandas-stubs/io/common.pyi @@ -1,65 +1,165 @@ from __future__ import annotations -from collections import abc -from io import BytesIO +from abc import ( + ABC, + ABCMeta, + abstractmethod, +) +from io import ( + BytesIO, + StringIO, + TextIOBase, +) +from pathlib import Path +import tarfile from typing import ( IO, - Any, AnyStr, - Mapping, + Generic, + Literal, + TypeVar, + overload, ) import zipfile -from pandas._typing import FilePathOrBuffer +from pandas._typing import ( + BaseBuffer, + CompressionDict, + CompressionOptions, + FilePath, + ReadBuffer, + StorageOptions, + WriteBuffer, +) + +_BaseBufferT = TypeVar("_BaseBufferT", bound=BaseBuffer) + +class IOArgs: + filepath_or_buffer: str | BaseBuffer + encoding: str + mode: str + compression: CompressionDict + should_close: bool + def __init__( + self, filepath_or_buffer, encoding, mode, compression, should_close + ) -> None: ... -lzma = ... +class IOHandles(Generic[AnyStr]): + handle: IO[AnyStr] + compression: CompressionDict + created_handles: list[IO[bytes] | IO[str]] + is_wrapped: bool + def close(self) -> None: ... + def __enter__(self) -> IOHandles[AnyStr]: ... + def __exit__(self, *args: object) -> None: ... + def __init__(self, handle, compression, created_handles, is_wrapped) -> None: ... -def is_url(url) -> bool: ... -def validate_header_arg(header) -> None: ... +def is_url(url: object) -> bool: ... +def validate_header_arg(header: object) -> None: ... +@overload def stringify_path( - filepath_or_buffer: FilePathOrBuffer[AnyStr], -) -> FilePathOrBuffer[AnyStr]: ... -def is_s3_url(url) -> bool: ... -def is_gcs_url(url) -> bool: ... -def urlopen(*args, **kwargs) -> IO: ... -def get_filepath_or_buffer( - filepath_or_buffer: FilePathOrBuffer, - encoding: str | None = ..., - compression: str | None = ..., - mode: str | None = ..., -): ... + filepath_or_buffer: FilePath, convert_file_like: bool = ... +) -> str: ... +@overload +def stringify_path( + filepath_or_buffer: _BaseBufferT, convert_file_like: bool = ... +) -> _BaseBufferT: ... +def urlopen(*args, **kwargs): ... +def is_fsspec_url(url: FilePath | BaseBuffer) -> bool: ... def file_path_to_url(path: str) -> str: ... def get_compression_method( - compression: str | Mapping[str, str] | None -) -> tuple[str | None, dict[str, str]]: ... + compression: CompressionOptions, +) -> tuple[str | None, CompressionDict]: ... def infer_compression( - filepath_or_buffer: FilePathOrBuffer, compression: str | None + filepath_or_buffer: FilePath | BaseBuffer, compression: str | None ) -> str | None: ... +def check_parent_directory(path: Path | str) -> None: ... +@overload def get_handle( - path_or_buf, + path_or_buf: FilePath | BaseBuffer, mode: str, - encoding=..., - compression: str | Mapping[str, Any] | None = ..., + *, + encoding: str | None = ..., + compression: CompressionOptions = ..., + memory_map: bool = ..., + is_text: Literal[False], + errors: str | None = ..., + storage_options: StorageOptions = ..., +) -> IOHandles[bytes]: ... +@overload +def get_handle( + path_or_buf: FilePath | BaseBuffer, + mode: str, + *, + encoding: str | None = ..., + compression: CompressionOptions = ..., + memory_map: bool = ..., + is_text: Literal[True] = ..., + errors: str | None = ..., + storage_options: StorageOptions = ..., +) -> IOHandles[str]: ... +@overload +def get_handle( + path_or_buf: FilePath | BaseBuffer, + mode: str, + *, + encoding: str | None = ..., + compression: CompressionOptions = ..., memory_map: bool = ..., is_text: bool = ..., -): ... + errors: str | None = ..., + storage_options: StorageOptions = ..., +) -> IOHandles[str] | IOHandles[bytes]: ... -# ignore similar to what is in pandas source -class _BytesZipFile(zipfile.ZipFile, BytesIO): # type: ignore[misc] - archive_name = ... +class _BufferedWriter(BytesIO, ABC, metaclass=ABCMeta): + @abstractmethod + def write_to_buffer(self) -> None: ... + def close(self) -> None: ... + def __enter__(self) -> _BufferedWriter: ... + +class _BytesTarFile(_BufferedWriter): + archive_name: str | None + name: str + buffer: tarfile.TarFile def __init__( self, - file: FilePathOrBuffer, + name: str | None = ..., + mode: Literal["r", "a", "w", "x"] = ..., + fileobj: ReadBuffer[bytes] | WriteBuffer[bytes] | None = ..., + archive_name: str | None = ..., + **kwargs, + ) -> None: ... + def extend_mode(self, mode: str) -> str: ... + def infer_filename(self) -> str | None: ... + def write_to_buffer(self) -> None: ... + +class _BytesZipFile(_BufferedWriter): + archive_name: str | None + buffer: zipfile.ZipFile + def __init__( + self, + file: FilePath | ReadBuffer[bytes] | WriteBuffer[bytes], mode: str, archive_name: str | None = ..., **kwargs, ) -> None: ... - @property - def closed(self) -> bool: ... + def infer_filename(self) -> str | None: ... + def write_to_buffer(self) -> None: ... -class _MMapWrapper(abc.Iterator): - mmap = ... - def __init__(self, f: IO) -> None: ... +class _IOWrapper: + buffer: BaseBuffer + def __init__(self, buffer: BaseBuffer) -> None: ... def __getattr__(self, name: str): ... - def __iter__(self) -> _MMapWrapper: ... - def __next__(self) -> str: ... + def readable(self) -> bool: ... + def seekable(self) -> bool: ... + def writable(self) -> bool: ... + +class _BytesIOWrapper: + buffer: StringIO | TextIOBase + encoding: str + overflow: bytes + def __init__(self, buffer: StringIO | TextIOBase, encoding: str = ...) -> None: ... + def __getattr__(self, attr: str): ... + def read(self, n: int | None = ...) -> bytes: ... + +def file_exists(filepath_or_buffer: FilePath | BaseBuffer) -> bool: ... diff --git a/pandas-stubs/io/feather_format.pyi b/pandas-stubs/io/feather_format.pyi index f2199e918..9bb2b2811 100644 --- a/pandas-stubs/io/feather_format.pyi +++ b/pandas-stubs/io/feather_format.pyi @@ -1,8 +1,5 @@ from __future__ import annotations -from typing import Sequence - - from pandas.core.frame import DataFrame from pandas._typing import ( diff --git a/pandas-stubs/io/html.pyi b/pandas-stubs/io/html.pyi index 1025489a8..6a954ab2d 100644 --- a/pandas-stubs/io/html.pyi +++ b/pandas-stubs/io/html.pyi @@ -2,23 +2,31 @@ from __future__ import annotations from typing import ( Any, - Callable, - Iterable, - Mapping, + Pattern, Sequence, ) from pandas.core.frame import DataFrame -from pandas._typing import FilePathOrBuffer +from pandas._typing import ( + FilePath, + ReadBuffer, +) class _HtmlFrameParser: - io = ... - match = ... - attrs = ... - encoding = ... - displayed_only = ... - def __init__(self, io, match, attrs, encoding, displayed_only) -> None: ... + io: FilePath | ReadBuffer[str] | ReadBuffer[bytes] + match: str | Pattern + attrs: dict[str, str] | None + encoding: str + displayed_only: bool + def __init__( + self, + io: FilePath | ReadBuffer[str] | ReadBuffer[bytes], + match: str | Pattern, + attrs: dict[str, str] | None, + encoding: str, + displayed_only: bool, + ) -> None: ... def parse_tables(self): ... class _BeautifulSoupHtml5LibFrameParser(_HtmlFrameParser): @@ -28,21 +36,19 @@ class _LxmlFrameParser(_HtmlFrameParser): def __init__(self, *args, **kwargs) -> None: ... def read_html( - io: FilePathOrBuffer, - match: str = ..., + io: FilePath | ReadBuffer[str], + match: str | Pattern = ..., flavor: str | None = ..., header: int | Sequence[int] | None = ..., - index_col: int | Sequence[Any] | None = ..., - skiprows: int | Sequence[Any] | slice | None = ..., - attrs: Mapping[str, str] | None = ..., - parse_dates: bool - | Sequence[int | str | Sequence[int | str]] - | dict[str, Sequence[int | str]] = ..., - thousands: str = ..., + index_col: int | Sequence[int] | None = ..., + skiprows: int | Sequence[int] | slice | None = ..., + attrs: dict[str, str] | None = ..., + parse_dates: bool = ..., + thousands: str | None = ..., encoding: str | None = ..., decimal: str = ..., - converters: Mapping[int | str, Callable] | None = ..., - na_values: Iterable[Any] | None = ..., + converters: dict | None = ..., + na_values: list[Any] | None = ..., keep_default_na: bool = ..., displayed_only: bool = ..., ) -> list[DataFrame]: ... From 01d11f00d9f96694fc40f6be99c84fd1bfa1752d Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Thu, 21 Jul 2022 18:39:47 +0100 Subject: [PATCH 4/5] CLN: Remove pyi files without an upstream py file --- pandas-stubs/io/parsers.pyi | 618 ------------------------------------ pandas-stubs/io/s3.pyi | 20 -- 2 files changed, 638 deletions(-) delete mode 100644 pandas-stubs/io/parsers.pyi delete mode 100644 pandas-stubs/io/s3.pyi diff --git a/pandas-stubs/io/parsers.pyi b/pandas-stubs/io/parsers.pyi deleted file mode 100644 index c20911cd1..000000000 --- a/pandas-stubs/io/parsers.pyi +++ /dev/null @@ -1,618 +0,0 @@ -from __future__ import annotations - -from collections import abc -from typing import ( - Callable, - Literal, - Protocol, - Sequence, - Union, - overload, -) - -import numpy as np -import pandas as pd -from pandas.core.frame import DataFrame - -from pandas._typing import ( - AnyStr_cov, - CompressionOptions, - DtypeArg, - FilePath, - FilePathOrBuffer, - ReadBuffer, - StorageOptions, -) - -ListLike = Union[ - list[Union[str, int]], - tuple[Union[str, int]], - set[Union[str, int]], - np.ndarray, - pd.Series, -] - -class ReadCsvBuffer(ReadBuffer[AnyStr_cov], Protocol): ... - -# read_csv engines -CSVEngine = Literal["c", "python", "pyarrow", "python-fwf"] - -# iterator=True -> TextFileReader -@overload -def read_csv( - filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], - *, - sep: str | None = ..., - delimiter: str | None = ..., - header: int | Sequence[int] | Literal["infer"] | None = ..., - names=..., - index_col=..., - usecols: ListLike | Callable | None = ..., - squeeze: bool | None = ..., - prefix: str | None = ..., - mangle_dupe_cols: bool = ..., - dtype: DtypeArg | None = ..., - engine: CSVEngine | None = ..., - converters=..., - true_values=..., - false_values=..., - skipinitialspace: bool = ..., - skiprows=..., - skipfooter: int = ..., - nrows: int | None = ..., - na_values=..., - keep_default_na: bool = ..., - na_filter: bool = ..., - verbose: bool = ..., - skip_blank_lines: bool = ..., - parse_dates=..., - infer_datetime_format: bool = ..., - keep_date_col: bool = ..., - date_parser=..., - dayfirst: bool = ..., - cache_dates: bool = ..., - iterator: Literal[True], - chunksize: int | None = ..., - compression: CompressionOptions = ..., - thousands: str | None = ..., - decimal: str = ..., - lineterminator: str | None = ..., - quotechar: str = ..., - quoting: int = ..., - doublequote: bool = ..., - escapechar: str | None = ..., - comment: str | None = ..., - encoding: str | None = ..., - encoding_errors: str | None = ..., - dialect=..., - error_bad_lines: bool | None = ..., - warn_bad_lines: bool | None = ..., - on_bad_lines=..., - delim_whitespace: bool = ..., - low_memory=..., - memory_map: bool = ..., - float_precision: Literal["high", "legacy"] | None = ..., - storage_options: StorageOptions | None = ..., -) -> TextFileReader: ... - -# chunksize=int -> TextFileReader -@overload -def read_csv( - filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], - *, - sep: str | None = ..., - delimiter: str | None = ..., - header: int | Sequence[int] | Literal["infer"] | None = ..., - names=..., - index_col=..., - usecols: ListLike | Callable | None = ..., - squeeze: bool | None = ..., - prefix: str | None = ..., - mangle_dupe_cols: bool = ..., - dtype: DtypeArg | None = ..., - engine: CSVEngine | None = ..., - converters=..., - true_values=..., - false_values=..., - skipinitialspace: bool = ..., - skiprows=..., - skipfooter: int = ..., - nrows: int | None = ..., - na_values=..., - keep_default_na: bool = ..., - na_filter: bool = ..., - verbose: bool = ..., - skip_blank_lines: bool = ..., - parse_dates=..., - infer_datetime_format: bool = ..., - keep_date_col: bool = ..., - date_parser=..., - dayfirst: bool = ..., - cache_dates: bool = ..., - iterator: bool = ..., - chunksize: int, - compression: CompressionOptions = ..., - thousands: str | None = ..., - decimal: str = ..., - lineterminator: str | None = ..., - quotechar: str = ..., - quoting: int = ..., - doublequote: bool = ..., - escapechar: str | None = ..., - comment: str | None = ..., - encoding: str | None = ..., - encoding_errors: str | None = ..., - dialect=..., - error_bad_lines: bool | None = ..., - warn_bad_lines: bool | None = ..., - on_bad_lines=..., - delim_whitespace: bool = ..., - low_memory=..., - memory_map: bool = ..., - float_precision: Literal["high", "legacy"] | None = ..., - storage_options: StorageOptions | None = ..., -) -> TextFileReader: ... - -# default case -> DataFrame -@overload -def read_csv( - filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], - *, - sep: str | None = ..., - delimiter: str | None = ..., - header: int | Sequence[int] | Literal["infer"] | None = ..., - names=..., - index_col=..., - usecols: ListLike | Callable | None = ..., - squeeze: bool | None = ..., - prefix: str | None = ..., - mangle_dupe_cols: bool = ..., - dtype: DtypeArg | None = ..., - engine: CSVEngine | None = ..., - converters=..., - true_values=..., - false_values=..., - skipinitialspace: bool = ..., - skiprows=..., - skipfooter: int = ..., - nrows: int | None = ..., - na_values=..., - keep_default_na: bool = ..., - na_filter: bool = ..., - verbose: bool = ..., - skip_blank_lines: bool = ..., - parse_dates=..., - infer_datetime_format: bool = ..., - keep_date_col: bool = ..., - date_parser=..., - dayfirst: bool = ..., - cache_dates: bool = ..., - iterator: Literal[False] = ..., - chunksize: None = ..., - compression: CompressionOptions = ..., - thousands: str | None = ..., - decimal: str = ..., - lineterminator: str | None = ..., - quotechar: str = ..., - quoting: int = ..., - doublequote: bool = ..., - escapechar: str | None = ..., - comment: str | None = ..., - encoding: str | None = ..., - encoding_errors: str | None = ..., - dialect=..., - error_bad_lines: bool | None = ..., - warn_bad_lines: bool | None = ..., - on_bad_lines=..., - delim_whitespace: bool = ..., - low_memory=..., - memory_map: bool = ..., - float_precision: Literal["high", "legacy"] | None = ..., - storage_options: StorageOptions | None = ..., -) -> DataFrame: ... - -# Unions -> DataFrame | TextFileReader -@overload -def read_csv( - filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], - *, - sep: str | None = ..., - delimiter: str | None = ..., - header: int | Sequence[int] | Literal["infer"] | None = ..., - names=..., - index_col=..., - usecols: ListLike | Callable | None = ..., - squeeze: bool | None = ..., - prefix: str | None = ..., - mangle_dupe_cols: bool = ..., - dtype: DtypeArg | None = ..., - engine: CSVEngine | None = ..., - converters=..., - true_values=..., - false_values=..., - skipinitialspace: bool = ..., - skiprows=..., - skipfooter: int = ..., - nrows: int | None = ..., - na_values=..., - keep_default_na: bool = ..., - na_filter: bool = ..., - verbose: bool = ..., - skip_blank_lines: bool = ..., - parse_dates=..., - infer_datetime_format: bool = ..., - keep_date_col: bool = ..., - date_parser=..., - dayfirst: bool = ..., - cache_dates: bool = ..., - iterator: bool = ..., - chunksize: int | None = ..., - compression: CompressionOptions = ..., - thousands: str | None = ..., - decimal: str = ..., - lineterminator: str | None = ..., - quotechar: str = ..., - quoting: int = ..., - doublequote: bool = ..., - escapechar: str | None = ..., - comment: str | None = ..., - encoding: str | None = ..., - encoding_errors: str | None = ..., - dialect=..., - error_bad_lines: bool | None = ..., - warn_bad_lines: bool | None = ..., - on_bad_lines=..., - delim_whitespace: bool = ..., - low_memory=..., - memory_map: bool = ..., - float_precision: Literal["high", "legacy"] | None = ..., - storage_options: StorageOptions | None = ..., -) -> DataFrame | TextFileReader: ... - -# iterator=True -> TextFileReader -@overload -def read_table( - filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], - *, - sep: str | None = ..., - delimiter: str | None = ..., - header: int | Sequence[int] | Literal["infer"] | None = ..., - names=..., - index_col=..., - usecols=..., - squeeze: bool | None = ..., - prefix: str | None = ..., - mangle_dupe_cols: bool = ..., - dtype: DtypeArg | None = ..., - engine: CSVEngine | None = ..., - converters=..., - true_values=..., - false_values=..., - skipinitialspace: bool = ..., - skiprows=..., - skipfooter: int = ..., - nrows: int | None = ..., - na_values=..., - keep_default_na: bool = ..., - na_filter: bool = ..., - verbose: bool = ..., - skip_blank_lines: bool = ..., - parse_dates=..., - infer_datetime_format: bool = ..., - keep_date_col: bool = ..., - date_parser=..., - dayfirst: bool = ..., - cache_dates: bool = ..., - iterator: Literal[True], - chunksize: int | None = ..., - compression: CompressionOptions = ..., - thousands: str | None = ..., - decimal: str = ..., - lineterminator: str | None = ..., - quotechar: str = ..., - quoting: int = ..., - doublequote: bool = ..., - escapechar: str | None = ..., - comment: str | None = ..., - encoding: str | None = ..., - encoding_errors: str | None = ..., - dialect=..., - error_bad_lines: bool | None = ..., - warn_bad_lines: bool | None = ..., - on_bad_lines=..., - delim_whitespace: bool = ..., - low_memory=..., - memory_map: bool = ..., - float_precision: Literal["high", "legacy"] | None = ..., - storage_options: StorageOptions | None = ..., -) -> TextFileReader: ... - -# chunksize=int -> TextFileReader -@overload -def read_table( - filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], - *, - sep: str | None = ..., - delimiter: str | None = ..., - header: int | Sequence[int] | Literal["infer"] | None = ..., - names=..., - index_col=..., - usecols=..., - squeeze: bool | None = ..., - prefix: str | None = ..., - mangle_dupe_cols: bool = ..., - dtype: DtypeArg | None = ..., - engine: CSVEngine | None = ..., - converters=..., - true_values=..., - false_values=..., - skipinitialspace: bool = ..., - skiprows=..., - skipfooter: int = ..., - nrows: int | None = ..., - na_values=..., - keep_default_na: bool = ..., - na_filter: bool = ..., - verbose: bool = ..., - skip_blank_lines: bool = ..., - parse_dates=..., - infer_datetime_format: bool = ..., - keep_date_col: bool = ..., - date_parser=..., - dayfirst: bool = ..., - cache_dates: bool = ..., - iterator: bool = ..., - chunksize: int, - compression: CompressionOptions = ..., - thousands: str | None = ..., - decimal: str = ..., - lineterminator: str | None = ..., - quotechar: str = ..., - quoting: int = ..., - doublequote: bool = ..., - escapechar: str | None = ..., - comment: str | None = ..., - encoding: str | None = ..., - encoding_errors: str | None = ..., - dialect=..., - error_bad_lines: bool | None = ..., - warn_bad_lines: bool | None = ..., - on_bad_lines=..., - delim_whitespace: bool = ..., - low_memory=..., - memory_map: bool = ..., - float_precision: Literal["high", "legacy"] | None = ..., - storage_options: StorageOptions | None = ..., -) -> TextFileReader: ... - -# default case -> DataFrame -@overload -def read_table( - filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], - *, - sep: str | None = ..., - delimiter: str | None = ..., - header: int | Sequence[int] | Literal["infer"] | None = ..., - names=..., - index_col=..., - usecols=..., - squeeze: bool | None = ..., - prefix: str | None = ..., - mangle_dupe_cols: bool = ..., - dtype: DtypeArg | None = ..., - engine: CSVEngine | None = ..., - converters=..., - true_values=..., - false_values=..., - skipinitialspace: bool = ..., - skiprows=..., - skipfooter: int = ..., - nrows: int | None = ..., - na_values=..., - keep_default_na: bool = ..., - na_filter: bool = ..., - verbose: bool = ..., - skip_blank_lines: bool = ..., - parse_dates=..., - infer_datetime_format: bool = ..., - keep_date_col: bool = ..., - date_parser=..., - dayfirst: bool = ..., - cache_dates: bool = ..., - iterator: Literal[False] = ..., - chunksize: None = ..., - compression: CompressionOptions = ..., - thousands: str | None = ..., - decimal: str = ..., - lineterminator: str | None = ..., - quotechar: str = ..., - quoting: int = ..., - doublequote: bool = ..., - escapechar: str | None = ..., - comment: str | None = ..., - encoding: str | None = ..., - encoding_errors: str | None = ..., - dialect=..., - error_bad_lines: bool | None = ..., - warn_bad_lines: bool | None = ..., - on_bad_lines=..., - delim_whitespace: bool = ..., - low_memory=..., - memory_map: bool = ..., - float_precision: Literal["high", "legacy"] | None = ..., - storage_options: StorageOptions | None = ..., -) -> DataFrame: ... - -# Unions -> DataFrame | TextFileReader -@overload -def read_table( - filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], - *, - sep: str | None = ..., - delimiter: str | None = ..., - header: int | Sequence[int] | Literal["infer"] | None = ..., - names=..., - index_col=..., - usecols=..., - squeeze: bool | None = ..., - prefix: str | None = ..., - mangle_dupe_cols: bool = ..., - dtype: DtypeArg | None = ..., - engine: CSVEngine | None = ..., - converters=..., - true_values=..., - false_values=..., - skipinitialspace: bool = ..., - skiprows=..., - skipfooter: int = ..., - nrows: int | None = ..., - na_values=..., - keep_default_na: bool = ..., - na_filter: bool = ..., - verbose: bool = ..., - skip_blank_lines: bool = ..., - parse_dates=..., - infer_datetime_format: bool = ..., - keep_date_col: bool = ..., - date_parser=..., - dayfirst: bool = ..., - cache_dates: bool = ..., - iterator: bool = ..., - chunksize: int | None = ..., - compression: CompressionOptions = ..., - thousands: str | None = ..., - decimal: str = ..., - lineterminator: str | None = ..., - quotechar: str = ..., - quoting: int = ..., - doublequote: bool = ..., - escapechar: str | None = ..., - comment: str | None = ..., - encoding: str | None = ..., - encoding_errors: str | None = ..., - dialect=..., - error_bad_lines: bool | None = ..., - warn_bad_lines: bool | None = ..., - on_bad_lines=..., - delim_whitespace: bool = ..., - low_memory=..., - memory_map: bool = ..., - float_precision: Literal["high", "legacy"] | None = ..., - storage_options: StorageOptions | None = ..., -) -> DataFrame | TextFileReader: ... -def read_fwf( - filepath_or_buffer: FilePathOrBuffer, - colspecs=..., - widths=..., - infer_nrows=..., - **kwds, -): ... - -class TextFileReader(abc.Iterator): - f = ... - orig_options = ... - engine = ... - chunksize = ... - nrows = ... - squeeze = ... - def __init__(self, f, engine=..., **kwds) -> None: ... - def close(self) -> None: ... - def __next__(self): ... - def read(self, nrows=...): ... - def get_chunk(self, size=...): ... - -class ParserBase: - names = ... - orig_names = ... - prefix = ... - index_col = ... - unnamed_cols = ... - index_names = ... - col_names = ... - parse_dates = ... - date_parser = ... - dayfirst = ... - keep_date_col = ... - na_values = ... - na_fvalues = ... - na_filter = ... - keep_default_na = ... - true_values = ... - false_values = ... - mangle_dupe_cols = ... - infer_datetime_format = ... - cache_dates = ... - header = ... - handles = ... - def __init__(self, kwds) -> None: ... - def close(self) -> None: ... - -class CParserWrapper(ParserBase): - kwds = ... - unnamed_cols = ... - names = ... - orig_names = ... - index_names = ... - def __init__(self, src, **kwds) -> None: ... - def close(self) -> None: ... - def set_error_bad_lines(self, status) -> None: ... - def read(self, nrows=...): ... - -def TextParser(*args, **kwds): ... -def count_empty_vals(vals): ... - -class PythonParser(ParserBase): - data = ... - buf = ... - pos: int = ... - line_pos: int = ... - encoding = ... - compression = ... - memory_map = ... - skiprows = ... - skipfunc = ... - skipfooter = ... - delimiter = ... - quotechar = ... - escapechar = ... - doublequote = ... - skipinitialspace = ... - lineterminator = ... - quoting = ... - skip_blank_lines = ... - warn_bad_lines = ... - error_bad_lines = ... - names_passed = ... - has_index_names: bool = ... - verbose = ... - converters = ... - dtype = ... - thousands = ... - decimal = ... - comment = ... - num_original_columns = ... - columns = ... - orig_names = ... - index_names = ... - nonnum = ... - def __init__(self, f, **kwds): ... - def read(self, rows=...): ... - def get_chunk(self, size=...): ... - -class FixedWidthReader(abc.Iterator): - f = ... - buffer = ... - delimiter = ... - comment = ... - colspecs = ... - def __init__( - self, f, colspecs, delimiter, comment, skiprows=..., infer_nrows: int = ... - ) -> None: ... - def get_rows(self, infer_nrows, skiprows=...): ... - def detect_colspecs(self, infer_nrows: int = ..., skiprows=...): ... - def __next__(self): ... - -class FixedWidthFieldParser(PythonParser): - colspecs = ... - infer_nrows = ... - def __init__(self, f, **kwds) -> None: ... diff --git a/pandas-stubs/io/s3.pyi b/pandas-stubs/io/s3.pyi deleted file mode 100644 index 63c53e297..000000000 --- a/pandas-stubs/io/s3.pyi +++ /dev/null @@ -1,20 +0,0 @@ -from __future__ import annotations - -from typing import ( - IO, - Any, -) - -from pandas._typing import FilePathOrBuffer - -s3fs = ... - -def get_file_and_filesystem( - filepath_or_buffer: FilePathOrBuffer, mode: str | None = ... -) -> tuple[IO, Any]: ... -def get_filepath_or_buffer( - filepath_or_buffer: FilePathOrBuffer, - encoding: str | None = ..., - compression: str | None = ..., - mode: str | None = ..., -) -> tuple[IO, str | None, str | None, bool]: ... From 495e206caede6ed15a893744ecdcd7497dee47b4 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Fri, 22 Jul 2022 09:57:03 +0100 Subject: [PATCH 5/5] ENH: Modernize io --- pandas-stubs/_libs/lib.pyi | 9 + pandas-stubs/_typing.pyi | 12 + pandas-stubs/io/date_converters.pyi | 2 +- pandas-stubs/io/excel/_odfreader.pyi | 26 + pandas-stubs/io/excel/_odswriter.pyi | 29 + pandas-stubs/io/excel/_openpyxl.pyi | 49 ++ pandas-stubs/io/excel/_pyxlsb.pyi | 23 + pandas-stubs/io/excel/_xlrd.pyi | 19 + pandas-stubs/io/excel/_xlsxwriter.pyi | 34 ++ pandas-stubs/io/excel/_xlwt.pyi | 32 ++ pandas-stubs/io/formats/_color_data.pyi | 1 + pandas-stubs/io/formats/html.pyi | 5 +- pandas-stubs/io/formats/info.pyi | 227 ++++++++ pandas-stubs/io/formats/latex.pyi | 4 +- pandas-stubs/io/formats/string.pyi | 12 + pandas-stubs/io/formats/style_render.pyi | 110 ++++ pandas-stubs/io/formats/xml.pyi | 83 +++ pandas-stubs/io/parsers/__init__.pyi | 7 + .../io/parsers/arrow_parser_wrapper.pyi | 16 + pandas-stubs/io/parsers/base_parser.pyi | 37 ++ pandas-stubs/io/parsers/c_parser_wrapper.pyi | 40 ++ pandas-stubs/io/parsers/python_parser.pyi | 92 ++++ pandas-stubs/io/parsers/readers.pyi | 513 ++++++++++++++++++ pandas-stubs/io/sas/_sas.pyi | 5 + 24 files changed, 1380 insertions(+), 7 deletions(-) create mode 100644 pandas-stubs/io/excel/_odfreader.pyi create mode 100644 pandas-stubs/io/excel/_odswriter.pyi create mode 100644 pandas-stubs/io/excel/_openpyxl.pyi create mode 100644 pandas-stubs/io/excel/_pyxlsb.pyi create mode 100644 pandas-stubs/io/excel/_xlrd.pyi create mode 100644 pandas-stubs/io/excel/_xlsxwriter.pyi create mode 100644 pandas-stubs/io/excel/_xlwt.pyi create mode 100644 pandas-stubs/io/formats/_color_data.pyi create mode 100644 pandas-stubs/io/formats/info.pyi create mode 100644 pandas-stubs/io/formats/string.pyi create mode 100644 pandas-stubs/io/formats/style_render.pyi create mode 100644 pandas-stubs/io/formats/xml.pyi create mode 100644 pandas-stubs/io/parsers/__init__.pyi create mode 100644 pandas-stubs/io/parsers/arrow_parser_wrapper.pyi create mode 100644 pandas-stubs/io/parsers/base_parser.pyi create mode 100644 pandas-stubs/io/parsers/c_parser_wrapper.pyi create mode 100644 pandas-stubs/io/parsers/python_parser.pyi create mode 100644 pandas-stubs/io/parsers/readers.pyi create mode 100644 pandas-stubs/io/sas/_sas.pyi diff --git a/pandas-stubs/_libs/lib.pyi b/pandas-stubs/_libs/lib.pyi index abe06e602..f32ff2f07 100644 --- a/pandas-stubs/_libs/lib.pyi +++ b/pandas-stubs/_libs/lib.pyi @@ -1,5 +1,14 @@ from __future__ import annotations +from enum import Enum + no_default = None +from typing import Literal + +class _NoDefault(Enum): + no_default = ... + +NoDefault = Literal[_NoDefault.no_default] + def infer_dtype(value: object, skipna: bool = ...) -> str: ... diff --git a/pandas-stubs/_typing.pyi b/pandas-stubs/_typing.pyi index ab4a9e21f..c6e13bb0e 100644 --- a/pandas-stubs/_typing.pyi +++ b/pandas-stubs/_typing.pyi @@ -16,6 +16,7 @@ from typing import ( AnyStr, Callable, Hashable, + Iterator, Literal, Mapping, Optional, @@ -77,6 +78,15 @@ class WriteBuffer(BaseBuffer, Protocol[AnyStr_cov]): ... class ReadPickleBuffer(ReadBuffer[bytes], Protocol): def readline(self) -> AnyStr_cov: ... +class WriteExcelBuffer(WriteBuffer[bytes], Protocol): + def truncate(self, size: int | None = ...) -> int: ... + +class ReadCsvBuffer(ReadBuffer[AnyStr_cov], Protocol): + def __iter__(self) -> Iterator[AnyStr_cov]: ... + def readline(self) -> AnyStr_cov: ... + @property + def closed(self) -> bool: ... + FilePath = Union[str, PathLike[str]] Buffer = Union[IO[AnyStr], RawIOBase, BufferedIOBase, TextIOBase, TextIOWrapper, mmap] @@ -218,4 +228,6 @@ GroupByObjectNonScalar = Union[ ] GroupByObject = Union[Scalar, GroupByObjectNonScalar] +CSVEngine = Literal["c", "python", "pyarrow", "python-fwf"] + __all__ = ["npt", "type_t"] diff --git a/pandas-stubs/io/date_converters.pyi b/pandas-stubs/io/date_converters.pyi index 08dd983d1..8eea25250 100644 --- a/pandas-stubs/io/date_converters.pyi +++ b/pandas-stubs/io/date_converters.pyi @@ -2,7 +2,7 @@ from __future__ import annotations import numpy as np -from pandas._typing import npt as npt +from pandas._typing import npt def parse_date_time(date_col, time_col) -> npt.NDArray[np.object_]: ... def parse_date_fields(year_col, month_col, day_col) -> npt.NDArray[np.object_]: ... diff --git a/pandas-stubs/io/excel/_odfreader.pyi b/pandas-stubs/io/excel/_odfreader.pyi new file mode 100644 index 000000000..e23917ff1 --- /dev/null +++ b/pandas-stubs/io/excel/_odfreader.pyi @@ -0,0 +1,26 @@ +from pandas._libs.tslibs.nattype import NaTType +from pandas._typing import ( + FilePath, + ReadBuffer, + Scalar, + StorageOptions, +) + +from pandas.io.excel._base import BaseExcelReader + +class ODFReader(BaseExcelReader): + def __init__( + self, + filepath_or_buffer: FilePath | ReadBuffer[bytes], + storage_options: StorageOptions = ..., + ) -> None: ... + def load_workbook(self, filepath_or_buffer: FilePath | ReadBuffer[bytes]): ... + @property + def empty_value(self) -> str: ... + @property + def sheet_names(self) -> list[str]: ... + def get_sheet_by_index(self, index: int): ... + def get_sheet_by_name(self, name: str): ... + def get_sheet_data( + self, sheet, convert_float: bool, file_rows_needed: int | None = ... + ) -> list[list[Scalar | NaTType]]: ... diff --git a/pandas-stubs/io/excel/_odswriter.pyi b/pandas-stubs/io/excel/_odswriter.pyi new file mode 100644 index 000000000..846e0de35 --- /dev/null +++ b/pandas-stubs/io/excel/_odswriter.pyi @@ -0,0 +1,29 @@ +from typing import Any + +from _typeshed import Incomplete + +from pandas._typing import ( + FilePath, + StorageOptions, + WriteExcelBuffer, +) + +from pandas.io.excel._base import ExcelWriter + +class ODSWriter(ExcelWriter): + def __init__( + self, + path: FilePath | WriteExcelBuffer | ExcelWriter, + engine: str | None = ..., + date_format: str | None = ..., + datetime_format: Incomplete | None = ..., + mode: str = ..., + storage_options: StorageOptions = ..., + if_sheet_exists: str | None = ..., + engine_kwargs: dict[str, Any] | None = ..., + **kwargs, + ) -> None: ... + @property + def book(self): ... + @property + def sheets(self) -> dict[str, Any]: ... diff --git a/pandas-stubs/io/excel/_openpyxl.pyi b/pandas-stubs/io/excel/_openpyxl.pyi new file mode 100644 index 000000000..82d60be01 --- /dev/null +++ b/pandas-stubs/io/excel/_openpyxl.pyi @@ -0,0 +1,49 @@ +from typing import Any + +from openpyxl.workbook import Workbook + +from pandas._typing import ( + FilePath, + ReadBuffer, + Scalar, + StorageOptions, + WriteExcelBuffer, +) + +from pandas.io.excel._base import ( + BaseExcelReader, + ExcelWriter, +) + +class OpenpyxlWriter(ExcelWriter): + def __init__( + self, + path: FilePath | WriteExcelBuffer | ExcelWriter, + engine: str | None = ..., + date_format: str | None = ..., + datetime_format: str | None = ..., + mode: str = ..., + storage_options: StorageOptions = ..., + if_sheet_exists: str | None = ..., + engine_kwargs: dict[str, Any] | None = ..., + **kwargs, + ) -> None: ... + @property + def book(self) -> Workbook: ... + @property + def sheets(self) -> dict[str, Any]: ... + +class OpenpyxlReader(BaseExcelReader): + def __init__( + self, + filepath_or_buffer: FilePath | ReadBuffer[bytes], + storage_options: StorageOptions = ..., + ) -> None: ... + def load_workbook(self, filepath_or_buffer: FilePath | ReadBuffer[bytes]): ... + @property + def sheet_names(self) -> list[str]: ... + def get_sheet_by_name(self, name: str): ... + def get_sheet_by_index(self, index: int): ... + def get_sheet_data( + self, sheet, convert_float: bool, file_rows_needed: int | None = ... + ) -> list[list[Scalar]]: ... diff --git a/pandas-stubs/io/excel/_pyxlsb.pyi b/pandas-stubs/io/excel/_pyxlsb.pyi new file mode 100644 index 000000000..3396ba13b --- /dev/null +++ b/pandas-stubs/io/excel/_pyxlsb.pyi @@ -0,0 +1,23 @@ +from pandas._typing import ( + FilePath, + ReadBuffer, + Scalar, + StorageOptions, +) + +from pandas.io.excel._base import BaseExcelReader + +class PyxlsbReader(BaseExcelReader): + def __init__( + self, + filepath_or_buffer: FilePath | ReadBuffer[bytes], + storage_options: StorageOptions = ..., + ) -> None: ... + def load_workbook(self, filepath_or_buffer: FilePath | ReadBuffer[bytes]): ... + @property + def sheet_names(self) -> list[str]: ... + def get_sheet_by_name(self, name: str): ... + def get_sheet_by_index(self, index: int): ... + def get_sheet_data( + self, sheet, convert_float: bool, file_rows_needed: int | None = ... + ) -> list[list[Scalar]]: ... diff --git a/pandas-stubs/io/excel/_xlrd.pyi b/pandas-stubs/io/excel/_xlrd.pyi new file mode 100644 index 000000000..edf351bab --- /dev/null +++ b/pandas-stubs/io/excel/_xlrd.pyi @@ -0,0 +1,19 @@ +from pandas._typing import ( + Scalar, + StorageOptions, +) + +from pandas.io.excel._base import BaseExcelReader + +class XlrdReader(BaseExcelReader): + def __init__( + self, filepath_or_buffer, storage_options: StorageOptions = ... + ) -> None: ... + def load_workbook(self, filepath_or_buffer): ... + @property + def sheet_names(self): ... + def get_sheet_by_name(self, name): ... + def get_sheet_by_index(self, index): ... + def get_sheet_data( + self, sheet, convert_float: bool, file_rows_needed: int | None = ... + ) -> list[list[Scalar]]: ... diff --git a/pandas-stubs/io/excel/_xlsxwriter.pyi b/pandas-stubs/io/excel/_xlsxwriter.pyi new file mode 100644 index 000000000..0621b476f --- /dev/null +++ b/pandas-stubs/io/excel/_xlsxwriter.pyi @@ -0,0 +1,34 @@ +from typing import Any + +from _typeshed import Incomplete + +from pandas._typing import ( + FilePath, + StorageOptions, + WriteExcelBuffer, +) + +from pandas.io.excel._base import ExcelWriter + +class _XlsxStyler: + STYLE_MAPPING: dict[str, list[tuple[tuple[str, ...], str]]] + @classmethod + def convert(cls, style_dict, num_format_str: Incomplete | None = ...): ... + +class XlsxWriter(ExcelWriter): + def __init__( + self, + path: FilePath | WriteExcelBuffer | ExcelWriter, + engine: str | None = ..., + date_format: str | None = ..., + datetime_format: str | None = ..., + mode: str = ..., + storage_options: StorageOptions = ..., + if_sheet_exists: str | None = ..., + engine_kwargs: dict[str, Any] | None = ..., + **kwargs, + ) -> None: ... + @property + def book(self): ... + @property + def sheets(self) -> dict[str, Any]: ... diff --git a/pandas-stubs/io/excel/_xlwt.pyi b/pandas-stubs/io/excel/_xlwt.pyi new file mode 100644 index 000000000..cf492542f --- /dev/null +++ b/pandas-stubs/io/excel/_xlwt.pyi @@ -0,0 +1,32 @@ +from typing import Any + +from pandas._typing import ( + FilePath, + StorageOptions, + WriteExcelBuffer, +) + +from pandas.io.excel._base import ExcelWriter + +class XlwtWriter(ExcelWriter): + def __init__( + self, + path: FilePath | WriteExcelBuffer | ExcelWriter, + engine: str | None = ..., + date_format: str | None = ..., + datetime_format: str | None = ..., + encoding: str | None = ..., + mode: str = ..., + storage_options: StorageOptions = ..., + if_sheet_exists: str | None = ..., + engine_kwargs: dict[str, Any] | None = ..., + **kwargs, + ) -> None: ... + @property + def book(self): ... + @property + def sheets(self) -> dict[str, Any]: ... + @property + def fm_date(self): ... + @property + def fm_datetime(self): ... diff --git a/pandas-stubs/io/formats/_color_data.pyi b/pandas-stubs/io/formats/_color_data.pyi new file mode 100644 index 000000000..4dd5eb808 --- /dev/null +++ b/pandas-stubs/io/formats/_color_data.pyi @@ -0,0 +1 @@ +CSS4_COLORS = ... # Incomplete diff --git a/pandas-stubs/io/formats/html.pyi b/pandas-stubs/io/formats/html.pyi index 4dd805f7f..d3c075753 100644 --- a/pandas-stubs/io/formats/html.pyi +++ b/pandas-stubs/io/formats/html.pyi @@ -5,10 +5,7 @@ from typing import ( Iterable, ) -from pandas.io.formats.format import ( - DataFrameFormatter as DataFrameFormatter, - TableFormatter as TableFormatter, -) +from pandas.io.formats.format import DataFrameFormatter class HTMLFormatter: indent_delta: int = ... diff --git a/pandas-stubs/io/formats/info.pyi b/pandas-stubs/io/formats/info.pyi new file mode 100644 index 000000000..e660c1b0d --- /dev/null +++ b/pandas-stubs/io/formats/info.pyi @@ -0,0 +1,227 @@ +import abc +from abc import ( + ABC, + abstractmethod, +) +from typing import ( + Iterable, + Mapping, + Sequence, +) + +from pandas.core.frame import DataFrame +from pandas.core.indexes.api import Index +from pandas.core.series import Series + +from pandas._config import get_option as get_option + +from pandas._typing import ( + Dtype, + WriteBuffer, +) + +from pandas.io.formats.printing import pprint_thing as pprint_thing + +frame_max_cols_sub = ... # Incomplete +show_counts_sub = ... # Incomplete +null_counts_sub = ... # Incomplete +frame_examples_sub = ... # Incomplete +frame_see_also_sub = ... # Incomplete +frame_sub_kwargs = ... # Incomplete +series_examples_sub = ... # Incomplete +series_see_also_sub = ... # Incomplete +series_sub_kwargs = ... # Incomplete +INFO_DOCSTRING = ... # Incomplete + +class BaseInfo(ABC, metaclass=abc.ABCMeta): + data: DataFrame | Series + memory_usage: bool | str + @property + @abstractmethod + def dtypes(self) -> Iterable[Dtype]: ... + @property + @abstractmethod + def dtype_counts(self) -> Mapping[str, int]: ... + @property + @abstractmethod + def non_null_counts(self) -> Sequence[int]: ... + @property + @abstractmethod + def memory_usage_bytes(self) -> int: ... + @property + def memory_usage_string(self) -> str: ... + @property + def size_qualifier(self) -> str: ... + @abstractmethod + def render( + self, + *, + buf: WriteBuffer[str] | None, + max_cols: int | None, + verbose: bool | None, + show_counts: bool | None, + ) -> None: ... + +class DataFrameInfo(BaseInfo): + data: DataFrame | Series + memory_usage: bool | str + def __init__( + self, data: DataFrame, memory_usage: bool | str | None = ... + ) -> None: ... + @property + def dtype_counts(self) -> Mapping[str, int]: ... + @property + def dtypes(self) -> Iterable[Dtype]: ... + @property + def ids(self) -> Index: ... + @property + def col_count(self) -> int: ... + @property + def non_null_counts(self) -> Sequence[int]: ... + @property + def memory_usage_bytes(self) -> int: ... + def render( + self, + *, + buf: WriteBuffer[str] | None, + max_cols: int | None, + verbose: bool | None, + show_counts: bool | None, + ) -> None: ... + +class SeriesInfo(BaseInfo): + data: DataFrame | Series + memory_usage: bool | str + def __init__(self, data: Series, memory_usage: bool | str | None = ...) -> None: ... + def render( + self, + *, + buf: WriteBuffer[str] | None = ..., + max_cols: int | None = ..., + verbose: bool | None = ..., + show_counts: bool | None = ..., + ) -> None: ... + @property + def non_null_counts(self) -> Sequence[int]: ... + @property + def dtypes(self) -> Iterable[Dtype]: ... + @property + def dtype_counts(self) -> Mapping[str, int]: ... + @property + def memory_usage_bytes(self) -> int: ... + +class InfoPrinterAbstract(metaclass=abc.ABCMeta): + def to_buffer(self, buf: WriteBuffer[str] | None = ...) -> None: ... + +class DataFrameInfoPrinter(InfoPrinterAbstract): + info = ... # Incomplete + data = ... # Incomplete + verbose = ... # Incomplete + max_cols = ... # Incomplete + show_counts = ... # Incomplete + def __init__( + self, + info: DataFrameInfo, + max_cols: int | None = ..., + verbose: bool | None = ..., + show_counts: bool | None = ..., + ) -> None: ... + @property + def max_rows(self) -> int: ... + @property + def exceeds_info_cols(self) -> bool: ... + @property + def exceeds_info_rows(self) -> bool: ... + @property + def col_count(self) -> int: ... + +class SeriesInfoPrinter(InfoPrinterAbstract): + info = ... # Incomplete + data = ... # Incomplete + verbose = ... # Incomplete + show_counts = ... # Incomplete + def __init__( + self, + info: SeriesInfo, + verbose: bool | None = ..., + show_counts: bool | None = ..., + ) -> None: ... + +class TableBuilderAbstract(ABC, metaclass=abc.ABCMeta): + info: BaseInfo + @abstractmethod + def get_lines(self) -> list[str]: ... + @property + def data(self) -> DataFrame | Series: ... + @property + def dtypes(self) -> Iterable[Dtype]: ... + @property + def dtype_counts(self) -> Mapping[str, int]: ... + @property + def display_memory_usage(self) -> bool: ... + @property + def memory_usage_string(self) -> str: ... + @property + def non_null_counts(self) -> Sequence[int]: ... + def add_object_type_line(self) -> None: ... + def add_index_range_line(self) -> None: ... + def add_dtypes_line(self) -> None: ... + +class DataFrameTableBuilder(TableBuilderAbstract, metaclass=abc.ABCMeta): + info: BaseInfo + def __init__(self, *, info: DataFrameInfo) -> None: ... + def get_lines(self) -> list[str]: ... + @property + def data(self) -> DataFrame: ... + @property + def ids(self) -> Index: ... + @property + def col_count(self) -> int: ... + def add_memory_usage_line(self) -> None: ... + +class DataFrameTableBuilderNonVerbose(DataFrameTableBuilder): + def add_columns_summary_line(self) -> None: ... + +class TableBuilderVerboseMixin(TableBuilderAbstract, metaclass=abc.ABCMeta): + SPACING: str + strrows: Sequence[Sequence[str]] + gross_column_widths: Sequence[int] + with_counts: bool + @property + @abstractmethod + def headers(self) -> Sequence[str]: ... + @property + def header_column_widths(self) -> Sequence[int]: ... + def add_header_line(self) -> None: ... + def add_separator_line(self) -> None: ... + def add_body_lines(self) -> None: ... + +class DataFrameTableBuilderVerbose(DataFrameTableBuilder, TableBuilderVerboseMixin): + info: DataFrameInfo + with_counts: bool + strrows: Sequence[Sequence[str]] + gross_column_widths: Sequence[int] + def __init__(self, *, info: DataFrameInfo, with_counts: bool) -> None: ... + @property + def headers(self) -> Sequence[str]: ... + def add_columns_summary_line(self) -> None: ... + +class SeriesTableBuilder(TableBuilderAbstract, metaclass=abc.ABCMeta): + info: BaseInfo + def __init__(self, *, info: SeriesInfo) -> None: ... + def get_lines(self) -> list[str]: ... + @property + def data(self) -> Series: ... + def add_memory_usage_line(self) -> None: ... + +class SeriesTableBuilderNonVerbose(SeriesTableBuilder): ... + +class SeriesTableBuilderVerbose(SeriesTableBuilder, TableBuilderVerboseMixin): + info: SeriesInfo + with_counts: bool + strrows: Sequence[Sequence[str]] + gross_column_widths: Sequence[int] + def __init__(self, *, info: SeriesInfo, with_counts: bool) -> None: ... + def add_series_name_line(self) -> None: ... + @property + def headers(self) -> Sequence[str]: ... diff --git a/pandas-stubs/io/formats/latex.pyi b/pandas-stubs/io/formats/latex.pyi index 27d942db5..640076d1e 100644 --- a/pandas-stubs/io/formats/latex.pyi +++ b/pandas-stubs/io/formats/latex.pyi @@ -3,8 +3,8 @@ from __future__ import annotations from typing import IO from pandas.io.formats.format import ( - DataFrameFormatter as DataFrameFormatter, - TableFormatter as TableFormatter, + DataFrameFormatter, + TableFormatter, ) class LatexFormatter(TableFormatter): diff --git a/pandas-stubs/io/formats/string.pyi b/pandas-stubs/io/formats/string.pyi new file mode 100644 index 000000000..69bdcaa29 --- /dev/null +++ b/pandas-stubs/io/formats/string.pyi @@ -0,0 +1,12 @@ +from pandas.io.formats.format import DataFrameFormatter +from pandas.io.formats.printing import pprint_thing as pprint_thing + +class StringFormatter: + fmt = ... # Incomplete + adj = ... # Incomplete + frame = ... # Incomplete + line_width = ... # Incomplete + def __init__( + self, fmt: DataFrameFormatter, line_width: int | None = ... + ) -> None: ... + def to_string(self) -> str: ... diff --git a/pandas-stubs/io/formats/style_render.pyi b/pandas-stubs/io/formats/style_render.pyi new file mode 100644 index 000000000..2ffd73a81 --- /dev/null +++ b/pandas-stubs/io/formats/style_render.pyi @@ -0,0 +1,110 @@ +from typing import ( + Any, + Callable, + Optional, + Sequence, + TypedDict, +) + +from pandas import ( + DataFrame, + Index, + Series, +) + +from pandas._typing import Level + +BaseFormatter = str | Callable +ExtFormatter = BaseFormatter | dict[Any, Optional[BaseFormatter]] +CSSPair = tuple[str, str | int | float] +CSSlist = list[CSSPair] +CSSProperties = str | CSSlist + +class CSSdict(TypedDict): + selector: str + props: CSSProperties + +CSSStyles = list[CSSdict] +Subset = slice | Sequence | Index + +class StylerRenderer: + loader = ... # Incomplete + env = ... # Incomplete + template_html = ... # Incomplete + template_html_table = ... # Incomplete + template_html_style = ... # Incomplete + template_latex = ... # Incomplete + template_string = ... # Incomplete + data = ... # Incomplete + index = ... # Incomplete + columns = ... # Incomplete + uuid = ... # Incomplete + uuid_len = ... # Incomplete + table_styles = ... # Incomplete + table_attributes = ... # Incomplete + caption = ... # Incomplete + cell_ids = ... # Incomplete + css = ... # Incomplete + concatenated = ... # Incomplete + hide_index_names: bool + hide_column_names: bool + hide_index_ = ... # Incomplete + hide_columns_ = ... # Incomplete + hidden_rows = ... # Incomplete + hidden_columns = ... # Incomplete + ctx = ... # Incomplete + ctx_index = ... # Incomplete + ctx_columns = ... # Incomplete + cell_context = ... # Incomplete + tooltips = ... # Incomplete + def __init__( + self, + data: DataFrame | Series, + uuid: str | None = ..., + uuid_len: int = ..., + table_styles: CSSStyles | None = ..., + table_attributes: str | None = ..., + caption: str | tuple | None = ..., + cell_ids: bool = ..., + precision: int | None = ..., + ): ... + def format( + self, + formatter: ExtFormatter | None = ..., + subset: Subset | None = ..., + na_rep: str | None = ..., + precision: int | None = ..., + decimal: str = ..., + thousands: str | None = ..., + escape: str | None = ..., + hyperlinks: str | None = ..., + ) -> StylerRenderer: ... + def format_index( + self, + formatter: ExtFormatter | None = ..., + axis: int | str = ..., + level: Level | list[Level] | None = ..., + na_rep: str | None = ..., + precision: int | None = ..., + decimal: str = ..., + thousands: str | None = ..., + escape: str | None = ..., + hyperlinks: str | None = ..., + ) -> StylerRenderer: ... + +def format_table_styles(styles: CSSStyles) -> CSSStyles: ... +def non_reducing_slice(slice_: Subset): ... +def maybe_convert_css_to_tuples(style: CSSProperties) -> CSSlist: ... +def refactor_levels(level: Level | list[Level] | None, obj: Index) -> list[int]: ... + +class Tooltips: + class_name = ... # Incomplete + class_properties = ... # Incomplete + tt_data = ... # Incomplete + table_styles = ... # Incomplete + def __init__( + self, + css_props: CSSProperties = ..., + css_name: str = ..., + tooltips: DataFrame = ..., + ) -> None: ... diff --git a/pandas-stubs/io/formats/xml.pyi b/pandas-stubs/io/formats/xml.pyi new file mode 100644 index 000000000..add84e561 --- /dev/null +++ b/pandas-stubs/io/formats/xml.pyi @@ -0,0 +1,83 @@ +from typing import Any + +from pandas.core.frame import DataFrame + +from pandas._typing import ( + CompressionOptions, + FilePath, + ReadBuffer, + StorageOptions, + WriteBuffer, +) + +class BaseXMLFormatter: + frame = ... # Incomplete + path_or_buffer = ... # Incomplete + index = ... # Incomplete + root_name = ... # Incomplete + row_name = ... # Incomplete + na_rep = ... # Incomplete + attr_cols = ... # Incomplete + elem_cols = ... # Incomplete + namespaces = ... # Incomplete + prefix = ... # Incomplete + encoding = ... # Incomplete + xml_declaration = ... # Incomplete + pretty_print = ... # Incomplete + stylesheet = ... # Incomplete + compression = ... # Incomplete + storage_options = ... # Incomplete + orig_cols = ... # Incomplete + frame_dicts = ... # Incomplete + prefix_uri = ... # Incomplete + def __init__( + self, + frame: DataFrame, + path_or_buffer: FilePath | WriteBuffer[bytes] | WriteBuffer[str] | None = ..., + index: bool = ..., + root_name: str | None = ..., + row_name: str | None = ..., + na_rep: str | None = ..., + attr_cols: list[str] | None = ..., + elem_cols: list[str] | None = ..., + namespaces: dict[str | None, str] | None = ..., + prefix: str | None = ..., + encoding: str = ..., + xml_declaration: bool | None = ..., + pretty_print: bool | None = ..., + stylesheet: FilePath | ReadBuffer[str] | ReadBuffer[bytes] | None = ..., + compression: CompressionOptions = ..., + storage_options: StorageOptions = ..., + ) -> None: ... + def build_tree(self) -> bytes: ... + def validate_columns(self) -> None: ... + def validate_encoding(self) -> None: ... + def process_dataframe(self) -> dict[int | str, dict[str, Any]]: ... + def handle_indexes(self) -> None: ... + def get_prefix_uri(self) -> str: ... + def other_namespaces(self) -> dict: ... + def build_attribs(self, d: dict[str, Any], elem_row: Any) -> Any: ... + def build_elems(self, d: dict[str, Any], elem_row: Any) -> None: ... + def write_output(self) -> str | None: ... + +class EtreeXMLFormatter(BaseXMLFormatter): + root = ... # Incomplete + elem_cols = ... # Incomplete + out_xml = ... # Incomplete + def build_tree(self) -> bytes: ... + def get_prefix_uri(self) -> str: ... + def build_elems(self, d: dict[str, Any], elem_row: Any) -> None: ... + def prettify_tree(self) -> bytes: ... + def add_declaration(self) -> bytes: ... + def remove_declaration(self) -> bytes: ... + +class LxmlXMLFormatter(BaseXMLFormatter): + def __init__(self, *args, **kwargs) -> None: ... + root = ... # Incomplete + elem_cols = ... # Incomplete + out_xml = ... # Incomplete + def build_tree(self) -> bytes: ... + def convert_empty_str_key(self) -> None: ... + def get_prefix_uri(self) -> str: ... + def build_elems(self, d: dict[str, Any], elem_row: Any) -> None: ... + def transform_doc(self) -> bytes: ... diff --git a/pandas-stubs/io/parsers/__init__.pyi b/pandas-stubs/io/parsers/__init__.pyi new file mode 100644 index 000000000..384829937 --- /dev/null +++ b/pandas-stubs/io/parsers/__init__.pyi @@ -0,0 +1,7 @@ +from pandas.io.parsers.readers import ( + TextFileReader as TextFileReader, + TextParser as TextParser, + read_csv as read_csv, + read_fwf as read_fwf, + read_table as read_table, +) diff --git a/pandas-stubs/io/parsers/arrow_parser_wrapper.pyi b/pandas-stubs/io/parsers/arrow_parser_wrapper.pyi new file mode 100644 index 000000000..a8f697bfa --- /dev/null +++ b/pandas-stubs/io/parsers/arrow_parser_wrapper.pyi @@ -0,0 +1,16 @@ +from pandas.core.frame import DataFrame + +from pandas._typing import ReadBuffer +from pandas.compat._optional import ( + import_optional_dependency as import_optional_dependency, +) + +from pandas.core.dtypes.inference import is_integer as is_integer + +from pandas.io.parsers.base_parser import ParserBase + +class ArrowParserWrapper(ParserBase): + kwds = ... # Incomplete + src = ... # Incomplete + def __init__(self, src: ReadBuffer[bytes], **kwds) -> None: ... + def read(self) -> DataFrame: ... diff --git a/pandas-stubs/io/parsers/base_parser.pyi b/pandas-stubs/io/parsers/base_parser.pyi new file mode 100644 index 000000000..c49599b1a --- /dev/null +++ b/pandas-stubs/io/parsers/base_parser.pyi @@ -0,0 +1,37 @@ +from enum import Enum + +class ParserBase: + class BadLineHandleMethod(Enum): + ERROR: int + WARN: int + SKIP: int + names = ... # Incomplete + orig_names = ... # Incomplete + prefix = ... # Incomplete + index_col = ... # Incomplete + unnamed_cols = ... # Incomplete + index_names = ... # Incomplete + col_names = ... # Incomplete + parse_dates = ... # Incomplete + date_parser = ... # Incomplete + dayfirst = ... # Incomplete + keep_date_col = ... # Incomplete + na_values = ... # Incomplete + na_fvalues = ... # Incomplete + na_filter = ... # Incomplete + keep_default_na = ... # Incomplete + dtype = ... # Incomplete + converters = ... # Incomplete + true_values = ... # Incomplete + false_values = ... # Incomplete + mangle_dupe_cols = ... # Incomplete + infer_datetime_format = ... # Incomplete + cache_dates = ... # Incomplete + header = ... # Incomplete + on_bad_lines = ... # Incomplete + def __init__(self, kwds) -> None: ... + def close(self) -> None: ... + +parser_defaults = ... # Incomplete + +def is_index_col(col) -> bool: ... diff --git a/pandas-stubs/io/parsers/c_parser_wrapper.pyi b/pandas-stubs/io/parsers/c_parser_wrapper.pyi new file mode 100644 index 000000000..1abed5a8b --- /dev/null +++ b/pandas-stubs/io/parsers/c_parser_wrapper.pyi @@ -0,0 +1,40 @@ +from typing import ( + Hashable, + Mapping, + Sequence, +) + +from pandas import ( + Index, + MultiIndex, +) + +from pandas._typing import ( + ArrayLike, + DtypeArg, + DtypeObj, + ReadCsvBuffer, +) + +from pandas.io.parsers.base_parser import ParserBase + +class CParserWrapper(ParserBase): + low_memory: bool + kwds = ... # Incomplete + unnamed_cols = ... # Incomplete + names = ... # Incomplete + orig_names = ... # Incomplete + index_names = ... # Incomplete + def __init__(self, src: ReadCsvBuffer[str], **kwds) -> None: ... + def close(self) -> None: ... + def read( + self, nrows: int | None = ... + ) -> tuple[ + Index | MultiIndex | None, + Sequence[Hashable] | MultiIndex, + Mapping[Hashable, ArrayLike], + ]: ... + +def ensure_dtype_objs( + dtype: DtypeArg | dict[Hashable, DtypeArg] | None +) -> DtypeObj | dict[Hashable, DtypeObj] | None: ... diff --git a/pandas-stubs/io/parsers/python_parser.pyi b/pandas-stubs/io/parsers/python_parser.pyi new file mode 100644 index 000000000..34d10ea80 --- /dev/null +++ b/pandas-stubs/io/parsers/python_parser.pyi @@ -0,0 +1,92 @@ +from collections import abc +from typing import ( + IO, + Hashable, + Literal, + Mapping, + Sequence, +) + +from pandas import ( + Index, + MultiIndex, +) + +from pandas._typing import ( + ArrayLike, + ReadCsvBuffer, +) + +from pandas.io.parsers.base_parser import ParserBase + +class PythonParser(ParserBase): + data = ... # Incomplete + buf = ... # Incomplete + pos: int + line_pos: int + skiprows = ... # Incomplete + skipfunc = ... # Incomplete + skipfooter = ... # Incomplete + delimiter = ... # Incomplete + quotechar = ... # Incomplete + escapechar = ... # Incomplete + doublequote = ... # Incomplete + skipinitialspace = ... # Incomplete + lineterminator = ... # Incomplete + quoting = ... # Incomplete + skip_blank_lines = ... # Incomplete + names_passed = ... # Incomplete + has_index_names: bool + verbose = ... # Incomplete + thousands = ... # Incomplete + decimal = ... # Incomplete + comment = ... # Incomplete + columns = ... # Incomplete + orig_names = ... # Incomplete + index_names = ... # Incomplete + num = ... # Incomplete + def __init__(self, f: ReadCsvBuffer[str] | list, **kwds): ... + def read( + self, rows: int | None = ... + ) -> tuple[ + Index | None, + Sequence[Hashable] | MultiIndex, + Hashable | ArrayLike, + ]: ... + def get_chunk( + self, size: int | None = ... + ) -> tuple[ + Index | None, + Sequence[Hashable] | MultiIndex, + Mapping[Hashable, ArrayLike], + ]: ... + +class FixedWidthReader(abc.Iterator): + f = ... # Incomplete + buffer = ... # Incomplete + delimiter = ... # Incomplete + comment = ... # Incomplete + colspecs = ... # Incomplete + def __init__( + self, + f: IO[str] | ReadCsvBuffer[str], + colspecs: list[tuple[int, int]] | Literal["infer"], + delimiter: str | None, + comment: str | None, + skiprows: set[int] | None = ..., + infer_nrows: int = ..., + ) -> None: ... + def get_rows( + self, infer_nrows: int, skiprows: set[int] | None = ... + ) -> list[str]: ... + def detect_colspecs( + self, infer_nrows: int = ..., skiprows: set[int] | None = ... + ) -> list[tuple[int, int]]: ... + def __next__(self) -> list[str]: ... + +class FixedWidthFieldParser(PythonParser): + colspecs = ... # Incomplete + infer_nrows = ... # Incomplete + def __init__(self, f: ReadCsvBuffer[str], **kwds) -> None: ... + +def count_empty_vals(vals) -> int: ... diff --git a/pandas-stubs/io/parsers/readers.pyi b/pandas-stubs/io/parsers/readers.pyi new file mode 100644 index 000000000..cfc3babee --- /dev/null +++ b/pandas-stubs/io/parsers/readers.pyi @@ -0,0 +1,513 @@ +from collections import abc +import csv +from typing import ( + Any, + Hashable, + Literal, + NamedTuple, + Sequence, + overload, +) + +from pandas.core.frame import DataFrame + +from pandas._libs import lib +from pandas._typing import ( + CompressionOptions, + CSVEngine, + DtypeArg, + FilePath, + IndexLabel, + ReadCsvBuffer, + StorageOptions, +) + +class _DeprecationConfig(NamedTuple): + default_value: Any + msg: str | None + +@overload +def validate_integer(name, val: None, min_val=...) -> None: ... +@overload +def validate_integer(name, val: int | float, min_val=...) -> int: ... +@overload +def validate_integer(name, val: int | None, min_val=...) -> int | None: ... +@overload +def read_csv( + filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], + *, + sep: str | lib.NoDefault | None = ..., + delimiter: str | lib.NoDefault | None = ..., + header: int | Sequence[int] | Literal["infer"] | None = ..., + names: Sequence[Hashable] | lib.NoDefault | None = ..., + index_col: IndexLabel | Literal[False] | None = ..., + usecols=..., + squeeze: bool | None = ..., + prefix: str | lib.NoDefault = ..., + mangle_dupe_cols: bool = ..., + dtype: DtypeArg | None = ..., + engine: CSVEngine | None = ..., + converters=..., + true_values=..., + false_values=..., + skipinitialspace: bool = ..., + skiprows=..., + skipfooter: int = ..., + nrows: int | None = ..., + na_values=..., + keep_default_na: bool = ..., + na_filter: bool = ..., + verbose: bool = ..., + skip_blank_lines: bool = ..., + parse_dates=..., + infer_datetime_format: bool = ..., + keep_date_col: bool = ..., + date_parser=..., + dayfirst: bool = ..., + cache_dates: bool = ..., + iterator: Literal[True], + chunksize: int | None = ..., + compression: CompressionOptions = ..., + thousands: str | None = ..., + decimal: str = ..., + lineterminator: str | None = ..., + quotechar: str = ..., + quoting: int = ..., + doublequote: bool = ..., + escapechar: str | None = ..., + comment: str | None = ..., + encoding: str | None = ..., + encoding_errors: str | None = ..., + dialect: str | csv.Dialect | None = ..., + error_bad_lines: bool | None = ..., + warn_bad_lines: bool | None = ..., + on_bad_lines=..., + delim_whitespace: bool = ..., + low_memory=..., + memory_map: bool = ..., + float_precision: Literal["high", "legacy"] | None = ..., + storage_options: StorageOptions = ..., +) -> TextFileReader: ... +@overload +def read_csv( + filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], + *, + sep: str | lib.NoDefault | None = ..., + delimiter: str | lib.NoDefault | None = ..., + header: int | Sequence[int] | Literal["infer"] | None = ..., + names: Sequence[Hashable] | None | lib.NoDefault = ..., + index_col: IndexLabel | Literal[False] | None = ..., + usecols=..., + squeeze: bool | None = ..., + prefix: str | lib.NoDefault = ..., + mangle_dupe_cols: bool = ..., + dtype: DtypeArg | None = ..., + engine: CSVEngine | None = ..., + converters=..., + true_values=..., + false_values=..., + skipinitialspace: bool = ..., + skiprows=..., + skipfooter: int = ..., + nrows: int | None = ..., + na_values=..., + keep_default_na: bool = ..., + na_filter: bool = ..., + verbose: bool = ..., + skip_blank_lines: bool = ..., + parse_dates=..., + infer_datetime_format: bool = ..., + keep_date_col: bool = ..., + date_parser=..., + dayfirst: bool = ..., + cache_dates: bool = ..., + iterator: bool = ..., + chunksize: int, + compression: CompressionOptions = ..., + thousands: str | None = ..., + decimal: str = ..., + lineterminator: str | None = ..., + quotechar: str = ..., + quoting: int = ..., + doublequote: bool = ..., + escapechar: str | None = ..., + comment: str | None = ..., + encoding: str | None = ..., + encoding_errors: str | None = ..., + dialect: str | csv.Dialect | None = ..., + error_bad_lines: bool | None = ..., + warn_bad_lines: bool | None = ..., + on_bad_lines=..., + delim_whitespace: bool = ..., + low_memory=..., + memory_map: bool = ..., + float_precision: Literal["high", "legacy"] | None = ..., + storage_options: StorageOptions = ..., +) -> TextFileReader: ... +@overload +def read_csv( + filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], + *, + sep: str | lib.NoDefault | None = ..., + delimiter: str | lib.NoDefault | None = ..., + header: int | Sequence[int] | Literal["infer"] | None = ..., + names: Sequence[Hashable] | None | lib.NoDefault = ..., + index_col: IndexLabel | Literal[False] | None = ..., + usecols=..., + squeeze: bool | None = ..., + prefix: str | lib.NoDefault = ..., + mangle_dupe_cols: bool = ..., + dtype: DtypeArg | None = ..., + engine: CSVEngine | None = ..., + converters=..., + true_values=..., + false_values=..., + skipinitialspace: bool = ..., + skiprows=..., + skipfooter: int = ..., + nrows: int | None = ..., + na_values=..., + keep_default_na: bool = ..., + na_filter: bool = ..., + verbose: bool = ..., + skip_blank_lines: bool = ..., + parse_dates=..., + infer_datetime_format: bool = ..., + keep_date_col: bool = ..., + date_parser=..., + dayfirst: bool = ..., + cache_dates: bool = ..., + iterator: Literal[False] = ..., + chunksize: None = ..., + compression: CompressionOptions = ..., + thousands: str | None = ..., + decimal: str = ..., + lineterminator: str | None = ..., + quotechar: str = ..., + quoting: int = ..., + doublequote: bool = ..., + escapechar: str | None = ..., + comment: str | None = ..., + encoding: str | None = ..., + encoding_errors: str | None = ..., + dialect: str | csv.Dialect | None = ..., + error_bad_lines: bool | None = ..., + warn_bad_lines: bool | None = ..., + on_bad_lines=..., + delim_whitespace: bool = ..., + low_memory=..., + memory_map: bool = ..., + float_precision: Literal["high", "legacy"] | None = ..., + storage_options: StorageOptions = ..., +) -> DataFrame: ... +@overload +def read_csv( + filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], + *, + sep: str | lib.NoDefault | None = ..., + delimiter: str | lib.NoDefault | None = ..., + header: int | Sequence[int] | Literal["infer"] | None = ..., + names: Sequence[Hashable] | None | lib.NoDefault = ..., + index_col: IndexLabel | Literal[False] | None = ..., + usecols=..., + squeeze: bool | None = ..., + prefix: str | lib.NoDefault = ..., + mangle_dupe_cols: bool = ..., + dtype: DtypeArg | None = ..., + engine: CSVEngine | None = ..., + converters=..., + true_values=..., + false_values=..., + skipinitialspace: bool = ..., + skiprows=..., + skipfooter: int = ..., + nrows: int | None = ..., + na_values=..., + keep_default_na: bool = ..., + na_filter: bool = ..., + verbose: bool = ..., + skip_blank_lines: bool = ..., + parse_dates=..., + infer_datetime_format: bool = ..., + keep_date_col: bool = ..., + date_parser=..., + dayfirst: bool = ..., + cache_dates: bool = ..., + iterator: bool = ..., + chunksize: int | None = ..., + compression: CompressionOptions = ..., + thousands: str | None = ..., + decimal: str = ..., + lineterminator: str | None = ..., + quotechar: str = ..., + quoting: int = ..., + doublequote: bool = ..., + escapechar: str | None = ..., + comment: str | None = ..., + encoding: str | None = ..., + encoding_errors: str | None = ..., + dialect: str | csv.Dialect | None = ..., + error_bad_lines: bool | None = ..., + warn_bad_lines: bool | None = ..., + on_bad_lines=..., + delim_whitespace: bool = ..., + low_memory=..., + memory_map: bool = ..., + float_precision: Literal["high", "legacy"] | None = ..., + storage_options: StorageOptions = ..., +) -> DataFrame | TextFileReader: ... +@overload +def read_table( + filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], + *, + sep: str | lib.NoDefault | None = ..., + delimiter: str | lib.NoDefault | None = ..., + header: int | Sequence[int] | Literal["infer"] | None = ..., + names: Sequence[Hashable] | None | lib.NoDefault = ..., + index_col: IndexLabel | Literal[False] | None = ..., + usecols=..., + squeeze: bool | None = ..., + prefix: str | lib.NoDefault = ..., + mangle_dupe_cols: bool = ..., + dtype: DtypeArg | None = ..., + engine: CSVEngine | None = ..., + converters=..., + true_values=..., + false_values=..., + skipinitialspace: bool = ..., + skiprows=..., + skipfooter: int = ..., + nrows: int | None = ..., + na_values=..., + keep_default_na: bool = ..., + na_filter: bool = ..., + verbose: bool = ..., + skip_blank_lines: bool = ..., + parse_dates=..., + infer_datetime_format: bool = ..., + keep_date_col: bool = ..., + date_parser=..., + dayfirst: bool = ..., + cache_dates: bool = ..., + iterator: Literal[True], + chunksize: int | None = ..., + compression: CompressionOptions = ..., + thousands: str | None = ..., + decimal: str = ..., + lineterminator: str | None = ..., + quotechar: str = ..., + quoting: int = ..., + doublequote: bool = ..., + escapechar: str | None = ..., + comment: str | None = ..., + encoding: str | None = ..., + encoding_errors: str | None = ..., + dialect: str | csv.Dialect | None = ..., + error_bad_lines: bool | None = ..., + warn_bad_lines: bool | None = ..., + on_bad_lines=..., + delim_whitespace=..., + low_memory=..., + memory_map: bool = ..., + float_precision: str | None = ..., + storage_options: StorageOptions = ..., +) -> TextFileReader: ... +@overload +def read_table( + filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], + *, + sep: str | lib.NoDefault | None = ..., + delimiter: str | lib.NoDefault | None = ..., + header: int | Sequence[int] | Literal["infer"] | None = ..., + names: Sequence[Hashable] | None | lib.NoDefault = ..., + index_col: IndexLabel | Literal[False] | None = ..., + usecols=..., + squeeze: bool | None = ..., + prefix: str | lib.NoDefault = ..., + mangle_dupe_cols: bool = ..., + dtype: DtypeArg | None = ..., + engine: CSVEngine | None = ..., + converters=..., + true_values=..., + false_values=..., + skipinitialspace: bool = ..., + skiprows=..., + skipfooter: int = ..., + nrows: int | None = ..., + na_values=..., + keep_default_na: bool = ..., + na_filter: bool = ..., + verbose: bool = ..., + skip_blank_lines: bool = ..., + parse_dates=..., + infer_datetime_format: bool = ..., + keep_date_col: bool = ..., + date_parser=..., + dayfirst: bool = ..., + cache_dates: bool = ..., + iterator: bool = ..., + chunksize: int, + compression: CompressionOptions = ..., + thousands: str | None = ..., + decimal: str = ..., + lineterminator: str | None = ..., + quotechar: str = ..., + quoting: int = ..., + doublequote: bool = ..., + escapechar: str | None = ..., + comment: str | None = ..., + encoding: str | None = ..., + encoding_errors: str | None = ..., + dialect: str | csv.Dialect | None = ..., + error_bad_lines: bool | None = ..., + warn_bad_lines: bool | None = ..., + on_bad_lines=..., + delim_whitespace=..., + low_memory=..., + memory_map: bool = ..., + float_precision: str | None = ..., + storage_options: StorageOptions = ..., +) -> TextFileReader: ... +@overload +def read_table( + filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], + *, + sep: str | lib.NoDefault | None = ..., + delimiter: str | lib.NoDefault | None = ..., + header: int | Sequence[int] | Literal["infer"] | None = ..., + names: Sequence[Hashable] | None | lib.NoDefault = ..., + index_col: IndexLabel | Literal[False] | None = ..., + usecols=..., + squeeze: bool | None = ..., + prefix: str | lib.NoDefault = ..., + mangle_dupe_cols: bool = ..., + dtype: DtypeArg | None = ..., + engine: CSVEngine | None = ..., + converters=..., + true_values=..., + false_values=..., + skipinitialspace: bool = ..., + skiprows=..., + skipfooter: int = ..., + nrows: int | None = ..., + na_values=..., + keep_default_na: bool = ..., + na_filter: bool = ..., + verbose: bool = ..., + skip_blank_lines: bool = ..., + parse_dates=..., + infer_datetime_format: bool = ..., + keep_date_col: bool = ..., + date_parser=..., + dayfirst: bool = ..., + cache_dates: bool = ..., + iterator: Literal[False] = ..., + chunksize: None = ..., + compression: CompressionOptions = ..., + thousands: str | None = ..., + decimal: str = ..., + lineterminator: str | None = ..., + quotechar: str = ..., + quoting: int = ..., + doublequote: bool = ..., + escapechar: str | None = ..., + comment: str | None = ..., + encoding: str | None = ..., + encoding_errors: str | None = ..., + dialect: str | csv.Dialect | None = ..., + error_bad_lines: bool | None = ..., + warn_bad_lines: bool | None = ..., + on_bad_lines=..., + delim_whitespace=..., + low_memory=..., + memory_map: bool = ..., + float_precision: str | None = ..., + storage_options: StorageOptions = ..., +) -> DataFrame: ... +@overload +def read_table( + filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], + *, + sep: str | lib.NoDefault | None = ..., + delimiter: str | lib.NoDefault | None = ..., + header: int | Sequence[int] | Literal["infer"] | None = ..., + names: Sequence[Hashable] | None | lib.NoDefault = ..., + index_col: IndexLabel | Literal[False] | None = ..., + usecols=..., + squeeze: bool | None = ..., + prefix: str | lib.NoDefault = ..., + mangle_dupe_cols: bool = ..., + dtype: DtypeArg | None = ..., + engine: CSVEngine | None = ..., + converters=..., + true_values=..., + false_values=..., + skipinitialspace: bool = ..., + skiprows=..., + skipfooter: int = ..., + nrows: int | None = ..., + na_values=..., + keep_default_na: bool = ..., + na_filter: bool = ..., + verbose: bool = ..., + skip_blank_lines: bool = ..., + parse_dates=..., + infer_datetime_format: bool = ..., + keep_date_col: bool = ..., + date_parser=..., + dayfirst: bool = ..., + cache_dates: bool = ..., + iterator: bool = ..., + chunksize: int | None = ..., + compression: CompressionOptions = ..., + thousands: str | None = ..., + decimal: str = ..., + lineterminator: str | None = ..., + quotechar: str = ..., + quoting: int = ..., + doublequote: bool = ..., + escapechar: str | None = ..., + comment: str | None = ..., + encoding: str | None = ..., + encoding_errors: str | None = ..., + dialect: str | csv.Dialect | None = ..., + error_bad_lines: bool | None = ..., + warn_bad_lines: bool | None = ..., + on_bad_lines=..., + delim_whitespace=..., + low_memory=..., + memory_map: bool = ..., + float_precision: str | None = ..., + storage_options: StorageOptions = ..., +) -> DataFrame | TextFileReader: ... +def read_fwf( + filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], + colspecs: Sequence[tuple[int, int]] | str | None = ..., + widths: Sequence[int] | None = ..., + infer_nrows: int = ..., + **kwds, +) -> DataFrame | TextFileReader: ... + +class TextFileReader(abc.Iterator): + engine = ... # Incomplete + orig_options = ... # Incomplete + chunksize = ... # Incomplete + nrows = ... # Incomplete + squeeze = ... # Incomplete + handles = ... # Incomplete + def __init__( + self, + f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, + engine: CSVEngine | None = ..., + **kwds, + ) -> None: ... + def close(self) -> None: ... + def __next__(self) -> DataFrame: ... + def read(self, nrows: int | None = ...) -> DataFrame: ... + def get_chunk(self, size: int | None = ...) -> DataFrame: ... + def __enter__(self) -> TextFileReader: ... + def __exit__(self, exc_type, exc_value, traceback) -> None: ... + +def TextParser(*args, **kwds) -> TextFileReader: ... + +MANDATORY_DIALECT_ATTRS = ... # Incomplete diff --git a/pandas-stubs/io/sas/_sas.pyi b/pandas-stubs/io/sas/_sas.pyi new file mode 100644 index 000000000..7b6a24aee --- /dev/null +++ b/pandas-stubs/io/sas/_sas.pyi @@ -0,0 +1,5 @@ +from pandas.io.sas.sas7bdat import SAS7BDATReader as SAS7BDATReader + +class Parser: + def __init__(self, parser: SAS7BDATReader) -> None: ... + def read(self, nrows: int) -> None: ...