From 51ec4d08b0f52835f3ecf0178fb4ab619c169060 Mon Sep 17 00:00:00 2001 From: Shing Chan Date: Sat, 9 Nov 2024 16:35:23 +0000 Subject: [PATCH 1/2] decorate read_* functions in readers.py with set_module('pandas') --- pandas/io/parsers/readers.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pandas/io/parsers/readers.py b/pandas/io/parsers/readers.py index ffc2690a5efdf..54877017f76fc 100644 --- a/pandas/io/parsers/readers.py +++ b/pandas/io/parsers/readers.py @@ -32,7 +32,10 @@ AbstractMethodError, ParserWarning, ) -from pandas.util._decorators import Appender +from pandas.util._decorators import ( + Appender, + set_module, +) from pandas.util._exceptions import find_stack_level from pandas.util._validators import check_dtype_backend @@ -771,6 +774,7 @@ def read_csv( % "filepath_or_buffer", ) ) +@set_module("pandas") def read_csv( filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], *, @@ -906,6 +910,7 @@ def read_table( % "filepath_or_buffer", ) ) +@set_module("pandas") def read_table( filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], *, @@ -1023,6 +1028,7 @@ def read_fwf( ) -> DataFrame: ... +@set_module("pandas") def read_fwf( filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], *, From 55a06bac66bc59d5280ca08f6e98fb163bb5a9bd Mon Sep 17 00:00:00 2001 From: Shing Chan Date: Sat, 9 Nov 2024 17:05:23 +0000 Subject: [PATCH 2/2] add asserts to test read function module string is set to 'pandas' --- pandas/tests/api/test_api.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index 842fa1a151267..e3234a466a05b 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -416,3 +416,6 @@ def test_set_module(): assert pd.Period.__module__ == "pandas" assert pd.Timestamp.__module__ == "pandas" assert pd.Timedelta.__module__ == "pandas" + assert pd.read_csv.__module__ == "pandas" + assert pd.read_table.__module__ == "pandas" + assert pd.read_fwf.__module__ == "pandas"