Skip to content

Commit

Permalink
Added types to df.info() (#875)
Browse files Browse the repository at this point in the history
Co-authored-by: Askhat Nuriddinov <[email protected]>
  • Loading branch information
askmyhat and askmyhat authored Feb 23, 2024
1 parent d2ffa32 commit 02abbdb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,12 @@ class DataFrame(NDFrame, OpsMixin):
storage_options: StorageOptions = ...,
) -> str: ...
def info(
self, verbose=..., buf=..., max_cols=..., memory_usage=..., null_counts=...
self,
verbose: bool | None = ...,
buf: WriteBuffer[str] = ...,
max_cols: int | None = ...,
memory_usage: bool | Literal["deep"] | None = ...,
show_counts: bool | None = ...,
) -> None: ...
def memory_usage(self, index: _bool = ..., deep: _bool = ...) -> Series: ...
def transpose(self, *args, copy: _bool = ...) -> DataFrame: ...
Expand Down
22 changes: 22 additions & 0 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3147,3 +3147,25 @@ def test_get() -> None:
pd.DataFrame,
)
check(assert_type(df.get(["z"], default=1), Union[pd.DataFrame, int]), int)


def test_info() -> None:
df = pd.DataFrame()

check(assert_type(df.info(verbose=True), None), type(None))
check(assert_type(df.info(verbose=False), None), type(None))
check(assert_type(df.info(verbose=None), None), type(None))

check(assert_type(df.info(buf=io.StringIO()), None), type(None))

check(assert_type(df.info(max_cols=1), None), type(None))
check(assert_type(df.info(max_cols=None), None), type(None))

check(assert_type(df.info(memory_usage=True), None), type(None))
check(assert_type(df.info(memory_usage=False), None), type(None))
check(assert_type(df.info(memory_usage="deep"), None), type(None))
check(assert_type(df.info(memory_usage=None), None), type(None))

check(assert_type(df.info(show_counts=True), None), type(None))
check(assert_type(df.info(show_counts=False), None), type(None))
check(assert_type(df.info(show_counts=None), None), type(None))

0 comments on commit 02abbdb

Please sign in to comment.