diff --git a/.pep8speaks.yml b/.pep8speaks.yml deleted file mode 100644 index 5a83727ddf5f8..0000000000000 --- a/.pep8speaks.yml +++ /dev/null @@ -1,4 +0,0 @@ -# File : .pep8speaks.yml - -scanner: - diff_only: True # If True, errors caused by only the patch are shown diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2f46190ef5eb7..131ef98985ae5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -71,7 +71,7 @@ repos: types: [text] # overwrite types: [rst] types_or: [python, rst] - repo: https://github.com/asottile/yesqa - rev: v1.2.2 + rev: v1.2.3 hooks: - id: yesqa additional_dependencies: diff --git a/pandas/core/array_algos/take.py b/pandas/core/array_algos/take.py index 93d87f6bb4dfa..bc1602525010e 100644 --- a/pandas/core/array_algos/take.py +++ b/pandas/core/array_algos/take.py @@ -26,26 +26,12 @@ from pandas.core.arrays.base import ExtensionArray +# fmt: off @overload -def take_nd( - arr: np.ndarray, - indexer, - axis: int = ..., - fill_value=..., - allow_fill: bool = ..., -) -> np.ndarray: - ... - - +def take_nd(arr: np.ndarray, indexer, axis: int = ..., fill_value=..., allow_fill: bool = ...) -> np.ndarray: ... # noqa: E501, E704 @overload -def take_nd( - arr: ExtensionArray, - indexer, - axis: int = ..., - fill_value=..., - allow_fill: bool = ..., -) -> ArrayLike: - ... +def take_nd(arr: ExtensionArray, indexer, axis: int = ..., fill_value=..., allow_fill: bool = ...) -> ArrayLike: ... # noqa: E501, E704 +# fmt: on def take_nd( diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 4a5dca348a8c0..f0ea724ca137f 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -427,21 +427,16 @@ def astype(self, dtype, copy: bool = True): else: return np.asarray(self, dtype=dtype) + # fmt: off @overload - def view(self: DatetimeLikeArrayT) -> DatetimeLikeArrayT: - ... - + def view(self: DatetimeLikeArrayT) -> DatetimeLikeArrayT: ... # noqa: E704 @overload - def view(self, dtype: Literal["M8[ns]"]) -> DatetimeArray: - ... - + def view(self, dtype: Literal["M8[ns]"]) -> DatetimeArray: ... # noqa: E704 @overload - def view(self, dtype: Literal["m8[ns]"]) -> TimedeltaArray: - ... - + def view(self, dtype: Literal["m8[ns]"]) -> TimedeltaArray: ... # noqa: E704 @overload - def view(self, dtype: Dtype | None = ...) -> ArrayLike: - ... + def view(self, dtype: Dtype | None = ...) -> ArrayLike: ... # noqa: E704 + # fmt: on def view(self, dtype: Dtype | None = None) -> ArrayLike: # We handle datetime64, datetime64tz, timedelta64, and period diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 289ed4948934f..eea8a852accbf 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -1918,18 +1918,12 @@ def std( # Constructor Helpers +# fmt: off @overload -def sequence_to_datetimes( - data, allow_object: Literal[False] = ..., require_iso8601: bool = ... -) -> DatetimeArray: - ... - - +def sequence_to_datetimes(data, allow_object: Literal[False] = ..., require_iso8601: bool = ...) -> DatetimeArray: ... # noqa: E501, E704 @overload -def sequence_to_datetimes( - data, allow_object: Literal[True] = ..., require_iso8601: bool = ... -) -> np.ndarray | DatetimeArray: - ... +def sequence_to_datetimes(data, allow_object: Literal[True] = ..., require_iso8601: bool = ...) -> np.ndarray | DatetimeArray: ... # noqa: E501, E704 +# fmt: on def sequence_to_datetimes( diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index d739b46620032..1d14d007bd14c 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -445,14 +445,12 @@ def maybe_cast_to_extension_array( return result +# fmt: off @overload -def ensure_dtype_can_hold_na(dtype: np.dtype) -> np.dtype: - ... - - +def ensure_dtype_can_hold_na(dtype: np.dtype) -> np.dtype: ... # noqa: E704 @overload -def ensure_dtype_can_hold_na(dtype: ExtensionDtype) -> ExtensionDtype: - ... +def ensure_dtype_can_hold_na(dtype: ExtensionDtype) -> ExtensionDtype: ... # noqa: E704 +# fmt: on def ensure_dtype_can_hold_na(dtype: DtypeObj) -> DtypeObj: @@ -1059,18 +1057,12 @@ def astype_td64_unit_conversion( return result +# fmt: off @overload -def astype_nansafe( - arr: np.ndarray, dtype: np.dtype, copy: bool = ..., skipna: bool = ... -) -> np.ndarray: - ... - - +def astype_nansafe(arr: np.ndarray, dtype: np.dtype, copy: bool = ..., skipna: bool = ...) -> np.ndarray: ... # noqa: E501, E704 @overload -def astype_nansafe( - arr: np.ndarray, dtype: ExtensionDtype, copy: bool = ..., skipna: bool = ... -) -> ExtensionArray: - ... +def astype_nansafe(arr: np.ndarray, dtype: ExtensionDtype, copy: bool = ..., skipna: bool = ...) -> ExtensionArray: ... # noqa: E501, E704 +# fmt: on def astype_nansafe( diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 7f970a72cb12c..04178a2491857 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1303,13 +1303,12 @@ def __len__(self) -> int: """ return len(self.index) + # fmt: off @overload - def dot(self, other: Series) -> Series: - ... - + def dot(self, other: Series) -> Series: ... # noqa: E704 @overload - def dot(self, other: DataFrame | Index | ArrayLike) -> DataFrame: - ... + def dot(self, other: DataFrame | Index | ArrayLike) -> DataFrame: ... # noqa: E704 + # fmt: on def dot(self, other: AnyArrayLike | FrameOrSeriesUnion) -> FrameOrSeriesUnion: """ @@ -1421,15 +1420,12 @@ def dot(self, other: AnyArrayLike | FrameOrSeriesUnion) -> FrameOrSeriesUnion: else: # pragma: no cover raise TypeError(f"unsupported type: {type(other)}") + # fmt: off @overload - def __matmul__(self, other: Series) -> Series: - ... - + def __matmul__(self, other: Series) -> Series: ... # noqa: E704 @overload - def __matmul__( - self, other: AnyArrayLike | FrameOrSeriesUnion - ) -> FrameOrSeriesUnion: - ... + def __matmul__(self, other: AnyArrayLike | FrameOrSeriesUnion) -> FrameOrSeriesUnion: ... # noqa: E501, E704 + # fmt: on def __matmul__( self, other: AnyArrayLike | FrameOrSeriesUnion @@ -4653,25 +4649,16 @@ def align( broadcast_axis=broadcast_axis, ) + # fmt: off @overload - def set_axis( - self, labels, axis: Axis = ..., inplace: Literal[False] = ... - ) -> DataFrame: - ... - + def set_axis(self, labels, axis: Axis = ..., inplace: Literal[False] = ...) -> DataFrame: ... # noqa: E501, E704 @overload - def set_axis(self, labels, axis: Axis, inplace: Literal[True]) -> None: - ... - + def set_axis(self, labels, axis: Axis, inplace: Literal[True]) -> None: ... # noqa: E501, E704 @overload - def set_axis(self, labels, *, inplace: Literal[True]) -> None: - ... - + def set_axis(self, labels, *, inplace: Literal[True]) -> None: ... # noqa: E704 @overload - def set_axis( - self, labels, axis: Axis = ..., inplace: bool = ... - ) -> DataFrame | None: - ... + def set_axis(self, labels, axis: Axis = ..., inplace: bool = ...) -> DataFrame | None: ... # noqa: E501, E704 + # fmt: on @Appender( """ @@ -5011,120 +4998,28 @@ def rename( errors=errors, ) + # fmt: off @overload - def fillna( - self, - value=..., - method: str | None = ..., - axis: Axis | None = ..., - inplace: Literal[False] = ..., - limit=..., - downcast=..., - ) -> DataFrame: - ... - + def fillna(self, value=..., method: str | None = ..., axis: Axis | None = ..., inplace: Literal[False] = ..., limit=..., downcast=...) -> DataFrame: ... # noqa: E501, E704 @overload - def fillna( - self, - value, - method: str | None, - axis: Axis | None, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, value, method: str | None, axis: Axis | None, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - *, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, *, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - value, - *, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, value, *, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - *, - method: str | None, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, *, method: str | None, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - *, - axis: Axis | None, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, *, axis: Axis | None, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - *, - method: str | None, - axis: Axis | None, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, *, method: str | None, axis: Axis | None, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - value, - *, - axis: Axis | None, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, value, *, axis: Axis | None, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - value, - method: str | None, - *, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, value, method: str | None, *, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - value=..., - method: str | None = ..., - axis: Axis | None = ..., - inplace: bool = ..., - limit=..., - downcast=..., - ) -> DataFrame | None: - ... + def fillna(self, value=..., method: str | None = ..., axis: Axis | None = ..., inplace: bool = ..., limit=..., downcast=...) -> DataFrame | None: ... # noqa: E501, E704 + # fmt: on @doc(NDFrame.fillna, **_shared_doc_kwargs) def fillna( @@ -5500,70 +5395,20 @@ def set_index( if not inplace: return frame + # fmt: off @overload - def reset_index( - self, - level: Hashable | Sequence[Hashable] | None = ..., - drop: bool = ..., - inplace: Literal[False] = ..., - col_level: Hashable = ..., - col_fill: Hashable = ..., - ) -> DataFrame: - ... - + def reset_index(self, level: Hashable | Sequence[Hashable] | None = ..., drop: bool = ..., inplace: Literal[False] = ..., col_level: Hashable = ..., col_fill: Hashable = ...) -> DataFrame: ... # noqa: E501, E704 @overload - def reset_index( - self, - level: Hashable | Sequence[Hashable] | None, - drop: bool, - inplace: Literal[True], - col_level: Hashable = ..., - col_fill: Hashable = ..., - ) -> None: - ... - + def reset_index(self, level: Hashable | Sequence[Hashable] | None, drop: bool, inplace: Literal[True], col_level: Hashable = ..., col_fill: Hashable = ...) -> None: ... # noqa: E501, E704 @overload - def reset_index( - self, - *, - drop: bool, - inplace: Literal[True], - col_level: Hashable = ..., - col_fill: Hashable = ..., - ) -> None: - ... - + def reset_index(self, *, drop: bool, inplace: Literal[True], col_level: Hashable = ..., col_fill: Hashable = ...) -> None: ... # noqa: E501, E704 @overload - def reset_index( - self, - level: Hashable | Sequence[Hashable] | None, - *, - inplace: Literal[True], - col_level: Hashable = ..., - col_fill: Hashable = ..., - ) -> None: - ... - + def reset_index(self, level: Hashable | Sequence[Hashable] | None, *, inplace: Literal[True], col_level: Hashable = ..., col_fill: Hashable = ...) -> None: ... # noqa: E501, E704 @overload - def reset_index( - self, - *, - inplace: Literal[True], - col_level: Hashable = ..., - col_fill: Hashable = ..., - ) -> None: - ... - + def reset_index(self, *, inplace: Literal[True], col_level: Hashable = ..., col_fill: Hashable = ...) -> None: ... # noqa: E501, E704 @overload - def reset_index( - self, - level: Hashable | Sequence[Hashable] | None = ..., - drop: bool = ..., - inplace: bool = ..., - col_level: Hashable = ..., - col_fill: Hashable = ..., - ) -> DataFrame | None: - ... + def reset_index(self, level: Hashable | Sequence[Hashable] | None = ..., drop: bool = ..., inplace: bool = ..., col_level: Hashable = ..., col_fill: Hashable = ...) -> DataFrame | None: ... # noqa: E501, E704 + # fmt: on def reset_index( self, diff --git a/pandas/core/generic.py b/pandas/core/generic.py index c77a3717c4c03..99483d9737f09 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -681,27 +681,16 @@ def size(self) -> int: # error: Incompatible return value type (got "number", expected "int") return np.prod(self.shape) # type: ignore[return-value] + # fmt: off @overload - def set_axis( - self: FrameOrSeries, labels, axis: Axis = ..., inplace: Literal[False] = ... - ) -> FrameOrSeries: - ... - + def set_axis(self: FrameOrSeries, labels, axis: Axis = ..., inplace: Literal[False] = ...) -> FrameOrSeries: ... # noqa: E501, E704 @overload - def set_axis( - self: FrameOrSeries, labels, axis: Axis, inplace: Literal[True] - ) -> None: - ... - + def set_axis(self: FrameOrSeries, labels, axis: Axis, inplace: Literal[True]) -> None: ... # noqa: E501, E704 @overload - def set_axis(self: FrameOrSeries, labels, *, inplace: Literal[True]) -> None: - ... - + def set_axis(self: FrameOrSeries, labels, *, inplace: Literal[True]) -> None: ... # noqa: E501, E704 @overload - def set_axis( - self: FrameOrSeries, labels, axis: Axis = ..., inplace: bool_t = ... - ) -> FrameOrSeries | None: - ... + def set_axis(self: FrameOrSeries, labels, axis: Axis = ..., inplace: bool_t = ...) -> FrameOrSeries | None: ... # noqa: E501, E704 + # fmt: on def set_axis(self, labels, axis: Axis = 0, inplace: bool_t = False): """ @@ -7363,113 +7352,28 @@ def _clip_with_one_bound(self, threshold, method, axis, inplace): # GH 40420 return self.where(subset, threshold, axis=axis, inplace=inplace) + # fmt: off @overload - def clip( - self: FrameOrSeries, - lower=..., - upper=..., - axis: Axis | None = ..., - inplace: Literal[False] = ..., - *args, - **kwargs, - ) -> FrameOrSeries: - ... - + def clip(self: FrameOrSeries, lower=..., upper=..., axis: Axis | None = ..., inplace: Literal[False] = ..., *args, **kwargs) -> FrameOrSeries: ... # noqa: E501, E704 @overload - def clip( - self: FrameOrSeries, - lower, - *, - axis: Axis | None, - inplace: Literal[True], - **kwargs, - ) -> None: - ... - + def clip(self: FrameOrSeries, lower, *, axis: Axis | None, inplace: Literal[True], **kwargs) -> None: ... # noqa: E501, E704 @overload - def clip( - self: FrameOrSeries, - lower, - *, - inplace: Literal[True], - **kwargs, - ) -> None: - ... - + def clip(self: FrameOrSeries, lower, *, inplace: Literal[True], **kwargs) -> None: ... # noqa: E501, E704 @overload - def clip( - self: FrameOrSeries, - *, - upper, - axis: Axis | None, - inplace: Literal[True], - **kwargs, - ) -> None: - ... - + def clip(self: FrameOrSeries, *, upper, axis: Axis | None, inplace: Literal[True], **kwargs) -> None: ... # noqa: E501, E704 @overload - def clip( - self: FrameOrSeries, - *, - upper, - inplace: Literal[True], - **kwargs, - ) -> None: - ... - + def clip(self: FrameOrSeries, *, upper, inplace: Literal[True], **kwargs) -> None: ... # noqa: E501, E704 @overload - def clip( - self: FrameOrSeries, - *, - axis: Axis | None, - inplace: Literal[True], - **kwargs, - ) -> None: - ... - + def clip(self: FrameOrSeries, *, axis: Axis | None, inplace: Literal[True], **kwargs) -> None: ... # noqa: E501, E704 @overload - def clip( - self: FrameOrSeries, - lower, - upper, - axis: Axis | None, - inplace: Literal[True], - *args, - **kwargs, - ) -> None: - ... - + def clip(self: FrameOrSeries, lower, upper, axis: Axis | None, inplace: Literal[True], *args, **kwargs) -> None: ... # noqa: E501, E704 @overload - def clip( - self: FrameOrSeries, - lower, - upper, - *, - inplace: Literal[True], - **kwargs, - ) -> None: - ... - + def clip(self: FrameOrSeries, lower, upper, *, inplace: Literal[True], **kwargs) -> None: ... # noqa: E501, E704 @overload - def clip( - self: FrameOrSeries, - *, - inplace: Literal[True], - **kwargs, - ) -> None: - ... - + def clip(self: FrameOrSeries, *, inplace: Literal[True], **kwargs) -> None: ... # noqa: E501, E704 @overload - def clip( - self: FrameOrSeries, - lower=..., - upper=..., - axis: Axis | None = ..., - inplace: bool_t = ..., - *args, - **kwargs, - ) -> FrameOrSeries | None: - ... + def clip(self: FrameOrSeries, lower=..., upper=..., axis: Axis | None = ..., inplace: bool_t = ..., *args, **kwargs) -> FrameOrSeries | None: ... # noqa: E501, E704 + # fmt: on @final def clip( diff --git a/pandas/core/reshape/concat.py b/pandas/core/reshape/concat.py index b3b453ea6355a..7e852a0e1352d 100644 --- a/pandas/core/reshape/concat.py +++ b/pandas/core/reshape/concat.py @@ -52,36 +52,12 @@ # Concatenate DataFrame objects +# fmt: off @overload -def concat( - objs: Iterable[DataFrame] | Mapping[Hashable, DataFrame], - axis=0, - join: str = "outer", - ignore_index: bool = False, - keys=None, - levels=None, - names=None, - verify_integrity: bool = False, - sort: bool = False, - copy: bool = True, -) -> DataFrame: - ... - - +def concat(objs: Iterable[DataFrame] | Mapping[Hashable, DataFrame], axis=0, join: str = "outer", ignore_index: bool = False, keys=None, levels=None, names=None, verify_integrity: bool = False, sort: bool = False, copy: bool = True) -> DataFrame: ... # noqa: E501, E704 @overload -def concat( - objs: Iterable[NDFrame] | Mapping[Hashable, NDFrame], - axis=0, - join: str = "outer", - ignore_index: bool = False, - keys=None, - levels=None, - names=None, - verify_integrity: bool = False, - sort: bool = False, - copy: bool = True, -) -> FrameOrSeriesUnion: - ... +def concat(objs: Iterable[NDFrame] | Mapping[Hashable, NDFrame], axis=0, join: str = "outer", ignore_index: bool = False, keys=None, levels=None, names=None, verify_integrity: bool = False, sort: bool = False, copy: bool = True) -> FrameOrSeriesUnion: ... # noqa: E501, E704 +# fmt: on def concat( diff --git a/pandas/core/series.py b/pandas/core/series.py index 85c30096b1001..c4551d93ffb2d 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2007,21 +2007,16 @@ def unique(self) -> ArrayLike: """ return super().unique() + # fmt: off @overload - def drop_duplicates(self, keep=..., inplace: Literal[False] = ...) -> Series: - ... - + def drop_duplicates(self, keep=..., inplace: Literal[False] = ...) -> Series: ... # noqa: E501, E704 @overload - def drop_duplicates(self, keep, inplace: Literal[True]) -> None: - ... - + def drop_duplicates(self, keep, inplace: Literal[True]) -> None: ... # noqa: E704 @overload - def drop_duplicates(self, *, inplace: Literal[True]) -> None: - ... - + def drop_duplicates(self, *, inplace: Literal[True]) -> None: ... # noqa: E704 @overload - def drop_duplicates(self, keep=..., inplace: bool = ...) -> Series | None: - ... + def drop_duplicates(self, keep=..., inplace: bool = ...) -> Series | None: ... # noqa: E501, E704 + # fmt: on def drop_duplicates(self, keep="first", inplace=False) -> Series | None: """ @@ -4428,23 +4423,16 @@ def rename( else: return self._set_name(index, inplace=inplace) + # fmt: off @overload - def set_axis( - self, labels, axis: Axis = ..., inplace: Literal[False] = ... - ) -> Series: - ... - + def set_axis(self, labels, axis: Axis = ..., inplace: Literal[False] = ...) -> Series: ... # noqa: E501, E704 @overload - def set_axis(self, labels, axis: Axis, inplace: Literal[True]) -> None: - ... - + def set_axis(self, labels, axis: Axis, inplace: Literal[True]) -> None: ... # noqa: E501, E704 @overload - def set_axis(self, labels, *, inplace: Literal[True]) -> None: - ... - + def set_axis(self, labels, *, inplace: Literal[True]) -> None: ... # noqa: E704 @overload - def set_axis(self, labels, axis: Axis = ..., inplace: bool = ...) -> Series | None: - ... + def set_axis(self, labels, axis: Axis = ..., inplace: bool = ...) -> Series | None: ... # noqa: E501, E704 + # fmt: on @Appender( """ @@ -4591,120 +4579,28 @@ def drop( errors=errors, ) + # fmt: off @overload - def fillna( - self, - value=..., - method: str | None = ..., - axis: Axis | None = ..., - inplace: Literal[False] = ..., - limit=..., - downcast=..., - ) -> Series: - ... - + def fillna(self, value=..., method: str | None = ..., axis: Axis | None = ..., inplace: Literal[False] = ..., limit=..., downcast=...) -> Series: ... # noqa: E501, E704 @overload - def fillna( - self, - value, - method: str | None, - axis: Axis | None, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, value, method: str | None, axis: Axis | None, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - *, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, *, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - value, - *, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, value, *, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - *, - method: str | None, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, *, method: str | None, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - *, - axis: Axis | None, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, *, axis: Axis | None, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - *, - method: str | None, - axis: Axis | None, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, *, method: str | None, axis: Axis | None, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - value, - *, - axis: Axis | None, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, value, *, axis: Axis | None, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - value, - method: str | None, - *, - inplace: Literal[True], - limit=..., - downcast=..., - ) -> None: - ... - + def fillna(self, value, method: str | None, *, inplace: Literal[True], limit=..., downcast=...) -> None: ... # noqa: E501, E704 @overload - def fillna( - self, - value=..., - method: str | None = ..., - axis: Axis | None = ..., - inplace: bool = ..., - limit=..., - downcast=..., - ) -> Series | None: - ... + def fillna(self, value=..., method: str | None = ..., axis: Axis | None = ..., inplace: bool = ..., limit=..., downcast=...) -> Series | None: ... # noqa: E501, E704 + # fmt: on # error: Cannot determine type of 'fillna' @doc(NDFrame.fillna, **_shared_doc_kwargs) # type: ignore[has-type] diff --git a/pandas/core/tools/datetimes.py b/pandas/core/tools/datetimes.py index bb37f670ed302..d107118db721c 100644 --- a/pandas/core/tools/datetimes.py +++ b/pandas/core/tools/datetimes.py @@ -641,55 +641,14 @@ def _adjust_to_origin(arg, origin, unit): return arg +# fmt: off @overload -def to_datetime( - arg: DatetimeScalar, - errors: str = ..., - dayfirst: bool = ..., - yearfirst: bool = ..., - utc: bool | None = ..., - format: str | None = ..., - exact: bool = ..., - unit: str | None = ..., - infer_datetime_format: bool = ..., - origin=..., - cache: bool = ..., -) -> DatetimeScalar | NaTType: - ... - - +def to_datetime(arg: DatetimeScalar, errors: str = ..., dayfirst: bool = ..., yearfirst: bool = ..., utc: bool | None = ..., format: str | None = ..., exact: bool = ..., unit: str | None = ..., infer_datetime_format: bool = ..., origin=..., cache: bool = ...) -> DatetimeScalar | NaTType: ... # noqa: E501, E704 @overload -def to_datetime( - arg: Series, - errors: str = ..., - dayfirst: bool = ..., - yearfirst: bool = ..., - utc: bool | None = ..., - format: str | None = ..., - exact: bool = ..., - unit: str | None = ..., - infer_datetime_format: bool = ..., - origin=..., - cache: bool = ..., -) -> Series: - ... - - +def to_datetime(arg: Series, errors: str = ..., dayfirst: bool = ..., yearfirst: bool = ..., utc: bool | None = ..., format: str | None = ..., exact: bool = ..., unit: str | None = ..., infer_datetime_format: bool = ..., origin=..., cache: bool = ...) -> Series: ... # noqa: E501, E704 @overload -def to_datetime( - arg: list | tuple | np.ndarray, - errors: str = ..., - dayfirst: bool = ..., - yearfirst: bool = ..., - utc: bool | None = ..., - format: str | None = ..., - exact: bool = ..., - unit: str | None = ..., - infer_datetime_format: bool = ..., - origin=..., - cache: bool = ..., -) -> DatetimeIndex: - ... +def to_datetime(arg: list | tuple | np.ndarray, errors: str = ..., dayfirst: bool = ..., yearfirst: bool = ..., utc: bool | None = ..., format: str | None = ..., exact: bool = ..., unit: str | None = ..., infer_datetime_format: bool = ..., origin=..., cache: bool = ...) -> DatetimeIndex: ... # noqa: E501, E704 +# fmt: on def to_datetime( diff --git a/pandas/io/sas/sasreader.py b/pandas/io/sas/sasreader.py index b323ce39763a1..704aa58674162 100644 --- a/pandas/io/sas/sasreader.py +++ b/pandas/io/sas/sasreader.py @@ -42,28 +42,12 @@ def __exit__(self, exc_type, exc_value, traceback): self.close() +# fmt: off @overload -def read_sas( - filepath_or_buffer: FilePathOrBuffer, - format: str | None = ..., - index: Hashable | None = ..., - encoding: str | None = ..., - chunksize: int = ..., - iterator: bool = ..., -) -> ReaderBase: - ... - - +def read_sas(filepath_or_buffer: FilePathOrBuffer, format: str | None = ..., index: Hashable | None = ..., encoding: str | None = ..., chunksize: int = ..., iterator: bool = ...) -> ReaderBase: ... # noqa: E501, E704 @overload -def read_sas( - filepath_or_buffer: FilePathOrBuffer, - format: str | None = ..., - index: Hashable | None = ..., - encoding: str | None = ..., - chunksize: None = ..., - iterator: bool = ..., -) -> DataFrame | ReaderBase: - ... +def read_sas(filepath_or_buffer: FilePathOrBuffer, format: str | None = ..., index: Hashable | None = ..., encoding: str | None = ..., chunksize: None = ..., iterator: bool = ...) -> DataFrame | ReaderBase: ... # noqa: E501, E704 +# fmt: on def read_sas( diff --git a/pandas/io/sql.py b/pandas/io/sql.py index d797fa51984d6..235433ca483af 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -211,32 +211,12 @@ def execute(sql, con, cur=None, params=None): # -- Read and write to DataFrames +# fmt: off @overload -def read_sql_table( - table_name, - con, - schema=None, - index_col=None, - coerce_float=True, - parse_dates=None, - columns=None, - chunksize: None = None, -) -> DataFrame: - ... - - +def read_sql_table(table_name, con, schema=None, index_col=None, coerce_float=True, parse_dates=None, columns=None, chunksize: None = None) -> DataFrame: ... # noqa: E501, E704 @overload -def read_sql_table( - table_name, - con, - schema=None, - index_col=None, - coerce_float=True, - parse_dates=None, - columns=None, - chunksize: int = 1, -) -> Iterator[DataFrame]: - ... +def read_sql_table(table_name, con, schema=None, index_col=None, coerce_float=True, parse_dates=None, columns=None, chunksize: int = 1) -> Iterator[DataFrame]: ... # noqa: E501, E704 +# fmt: on def read_sql_table( @@ -334,32 +314,12 @@ def read_sql_table( raise ValueError(f"Table {table_name} not found", con) +# fmt: off @overload -def read_sql_query( - sql, - con, - index_col=None, - coerce_float=True, - params=None, - parse_dates=None, - chunksize: None = None, - dtype: DtypeArg | None = None, -) -> DataFrame: - ... - - +def read_sql_query(sql, con, index_col=None, coerce_float=True, params=None, parse_dates=None, chunksize: None = None, dtype: DtypeArg | None = None) -> DataFrame: ... # noqa: E501, E704 @overload -def read_sql_query( - sql, - con, - index_col=None, - coerce_float=True, - params=None, - parse_dates=None, - chunksize: int = 1, - dtype: DtypeArg | None = None, -) -> Iterator[DataFrame]: - ... +def read_sql_query(sql, con, index_col=None, coerce_float=True, params=None, parse_dates=None, chunksize: int = 1, dtype: DtypeArg | None = None) -> Iterator[DataFrame]: ... # noqa: E501, E704 +# fmt: on def read_sql_query( @@ -441,32 +401,12 @@ def read_sql_query( ) +# fmt: off @overload -def read_sql( - sql, - con, - index_col=None, - coerce_float=True, - params=None, - parse_dates=None, - columns=None, - chunksize: None = None, -) -> DataFrame: - ... - - +def read_sql(sql, con, index_col=None, coerce_float=True, params=None, parse_dates=None, columns=None, chunksize: None = None) -> DataFrame: ... # noqa: E501, E704 @overload -def read_sql( - sql, - con, - index_col=None, - coerce_float=True, - params=None, - parse_dates=None, - columns=None, - chunksize: int = 1, -) -> Iterator[DataFrame]: - ... +def read_sql(sql, con, index_col=None, coerce_float=True, params=None, parse_dates=None, columns=None, chunksize: int = 1) -> Iterator[DataFrame]: ... # noqa: E501, E704 +# fmt: on def read_sql(