Skip to content

Commit 02abbdb

Browse files
authored
Added types to df.info() (#875)
Co-authored-by: Askhat Nuriddinov <[email protected]>
1 parent d2ffa32 commit 02abbdb

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

pandas-stubs/core/frame.pyi

+6-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,12 @@ class DataFrame(NDFrame, OpsMixin):
570570
storage_options: StorageOptions = ...,
571571
) -> str: ...
572572
def info(
573-
self, verbose=..., buf=..., max_cols=..., memory_usage=..., null_counts=...
573+
self,
574+
verbose: bool | None = ...,
575+
buf: WriteBuffer[str] = ...,
576+
max_cols: int | None = ...,
577+
memory_usage: bool | Literal["deep"] | None = ...,
578+
show_counts: bool | None = ...,
574579
) -> None: ...
575580
def memory_usage(self, index: _bool = ..., deep: _bool = ...) -> Series: ...
576581
def transpose(self, *args, copy: _bool = ...) -> DataFrame: ...

tests/test_frame.py

+22
Original file line numberDiff line numberDiff line change
@@ -3147,3 +3147,25 @@ def test_get() -> None:
31473147
pd.DataFrame,
31483148
)
31493149
check(assert_type(df.get(["z"], default=1), Union[pd.DataFrame, int]), int)
3150+
3151+
3152+
def test_info() -> None:
3153+
df = pd.DataFrame()
3154+
3155+
check(assert_type(df.info(verbose=True), None), type(None))
3156+
check(assert_type(df.info(verbose=False), None), type(None))
3157+
check(assert_type(df.info(verbose=None), None), type(None))
3158+
3159+
check(assert_type(df.info(buf=io.StringIO()), None), type(None))
3160+
3161+
check(assert_type(df.info(max_cols=1), None), type(None))
3162+
check(assert_type(df.info(max_cols=None), None), type(None))
3163+
3164+
check(assert_type(df.info(memory_usage=True), None), type(None))
3165+
check(assert_type(df.info(memory_usage=False), None), type(None))
3166+
check(assert_type(df.info(memory_usage="deep"), None), type(None))
3167+
check(assert_type(df.info(memory_usage=None), None), type(None))
3168+
3169+
check(assert_type(df.info(show_counts=True), None), type(None))
3170+
check(assert_type(df.info(show_counts=False), None), type(None))
3171+
check(assert_type(df.info(show_counts=None), None), type(None))

0 commit comments

Comments
 (0)