From 5d40776d6d20e13391c19b794f9b7bea67f4a4a2 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Wed, 12 Apr 2023 23:10:32 +0530 Subject: [PATCH 1/2] added infer to encoding --- pandas-stubs/io/sas/sasreader.pyi | 14 +++++++------- tests/test_io.py | 5 +++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pandas-stubs/io/sas/sasreader.pyi b/pandas-stubs/io/sas/sasreader.pyi index d988b1b9..298d1a5d 100644 --- a/pandas-stubs/io/sas/sasreader.pyi +++ b/pandas-stubs/io/sas/sasreader.pyi @@ -34,7 +34,7 @@ def read_sas( *, format: Literal["sas7bdat"], index: Hashable | None = ..., - encoding: str | None = ..., + encoding: Literal['infer'] | str | None = ..., chunksize: int, iterator: bool = ..., compression: CompressionOptions = ..., @@ -45,7 +45,7 @@ def read_sas( *, format: Literal["xport"], index: Hashable | None = ..., - encoding: str | None = ..., + encoding: Literal['infer'] | str | None = ..., chunksize: int, iterator: bool = ..., compression: CompressionOptions = ..., @@ -56,7 +56,7 @@ def read_sas( *, format: None = ..., index: Hashable | None = ..., - encoding: str | None = ..., + encoding: Literal['infer'] | str | None = ..., chunksize: int, iterator: bool = ..., compression: CompressionOptions = ..., @@ -67,7 +67,7 @@ def read_sas( *, format: Literal["sas7bdat"], index: Hashable | None = ..., - encoding: str | None = ..., + encoding: Literal['infer'] | str | None = ..., chunksize: int | None = ..., iterator: Literal[True], compression: CompressionOptions = ..., @@ -78,7 +78,7 @@ def read_sas( *, format: Literal["xport"], index: Hashable | None = ..., - encoding: str | None = ..., + encoding: Literal['infer'] | str | None = ..., chunksize: int | None = ..., iterator: Literal[True], compression: CompressionOptions = ..., @@ -89,7 +89,7 @@ def read_sas( *, format: None = ..., index: Hashable | None = ..., - encoding: str | None = ..., + encoding: Literal['infer'] | str | None = ..., chunksize: int | None = ..., iterator: Literal[True], compression: CompressionOptions = ..., @@ -100,7 +100,7 @@ def read_sas( *, format: Literal["xport", "sas7bdat"] | None = ..., index: Hashable | None = ..., - encoding: str | None = ..., + encoding: Literal['infer'] | str | None = ..., chunksize: None = ..., iterator: Literal[False] = ..., compression: CompressionOptions = ..., diff --git a/tests/test_io.py b/tests/test_io.py index e259b82e..caa77130 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1204,3 +1204,8 @@ def test_sqlalchemy_text() -> None: assert_type(read_sql(sql_select, con=conn), DataFrame), DataFrame, ) + + +def test_read_sas_encoding() -> None: + path = pathlib.Path("pandas", "stubs", "SSHSV1_A.xpt") + check(assert_type(read_sas(path, encoding='infer'), DataFrame), DataFrame) From f9e9d9475f66d437377d51350f21c8426399c4d1 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Thu, 13 Apr 2023 09:57:42 +0530 Subject: [PATCH 2/2] update --- pandas-stubs/io/sas/sasreader.pyi | 14 +++++++------- tests/test_io.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pandas-stubs/io/sas/sasreader.pyi b/pandas-stubs/io/sas/sasreader.pyi index 298d1a5d..10a4ae87 100644 --- a/pandas-stubs/io/sas/sasreader.pyi +++ b/pandas-stubs/io/sas/sasreader.pyi @@ -34,7 +34,7 @@ def read_sas( *, format: Literal["sas7bdat"], index: Hashable | None = ..., - encoding: Literal['infer'] | str | None = ..., + encoding: Literal["infer"] | None = ..., chunksize: int, iterator: bool = ..., compression: CompressionOptions = ..., @@ -45,7 +45,7 @@ def read_sas( *, format: Literal["xport"], index: Hashable | None = ..., - encoding: Literal['infer'] | str | None = ..., + encoding: Literal["infer"] | None = ..., chunksize: int, iterator: bool = ..., compression: CompressionOptions = ..., @@ -56,7 +56,7 @@ def read_sas( *, format: None = ..., index: Hashable | None = ..., - encoding: Literal['infer'] | str | None = ..., + encoding: Literal["infer"] | None = ..., chunksize: int, iterator: bool = ..., compression: CompressionOptions = ..., @@ -67,7 +67,7 @@ def read_sas( *, format: Literal["sas7bdat"], index: Hashable | None = ..., - encoding: Literal['infer'] | str | None = ..., + encoding: Literal["infer"] | None = ..., chunksize: int | None = ..., iterator: Literal[True], compression: CompressionOptions = ..., @@ -78,7 +78,7 @@ def read_sas( *, format: Literal["xport"], index: Hashable | None = ..., - encoding: Literal['infer'] | str | None = ..., + encoding: Literal["infer"] | None = ..., chunksize: int | None = ..., iterator: Literal[True], compression: CompressionOptions = ..., @@ -89,7 +89,7 @@ def read_sas( *, format: None = ..., index: Hashable | None = ..., - encoding: Literal['infer'] | str | None = ..., + encoding: Literal["infer"] | None = ..., chunksize: int | None = ..., iterator: Literal[True], compression: CompressionOptions = ..., @@ -100,7 +100,7 @@ def read_sas( *, format: Literal["xport", "sas7bdat"] | None = ..., index: Hashable | None = ..., - encoding: Literal['infer'] | str | None = ..., + encoding: Literal["infer"] | None = ..., chunksize: None = ..., iterator: Literal[False] = ..., compression: CompressionOptions = ..., diff --git a/tests/test_io.py b/tests/test_io.py index caa77130..42831552 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1207,5 +1207,5 @@ def test_sqlalchemy_text() -> None: def test_read_sas_encoding() -> None: - path = pathlib.Path("pandas", "stubs", "SSHSV1_A.xpt") - check(assert_type(read_sas(path, encoding='infer'), DataFrame), DataFrame) + path = pathlib.Path(CWD, "data", "airline.sas7bdat") + check(assert_type(read_sas(path), DataFrame), DataFrame)