diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 23c61773daf5a..84ab4fd5c60a1 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -5537,14 +5537,38 @@ def notna(self) -> DataFrame: def notnull(self) -> DataFrame: return ~self.isna() + @overload + # https://github.com/python/mypy/issues/6580 + # Overloaded function signatures 1 and 2 overlap with incompatible return types + def dropna( # type: ignore[misc] + self, + axis: Axis = ..., + how: str = ..., + thresh: Optional[int] = ..., + subset: Optional[Union[Hashable, Sequence[Hashable]]] = ..., + inplace: Literal[False] = ..., + ) -> DataFrame: + ... + + @overload + def dropna( + self, + axis: Axis = ..., + how: str = ..., + thresh: Optional[int] = ..., + subset: Optional[Union[Hashable, Sequence[Hashable]]] = ..., + inplace: Literal[True] = ..., + ) -> None: + ... + def dropna( self, axis: Axis = 0, how: str = "any", - thresh=None, - subset=None, + thresh: Optional[int] = None, + subset: Optional[Union[Hashable, Sequence[Hashable]]] = None, inplace: bool = False, - ): + ) -> Optional[DataFrame]: """ Remove missing values. @@ -5683,6 +5707,7 @@ def dropna( if inplace: self._update_inplace(result) + return None else: return result