From 28129e4e1ddfe252653c863a2ae548c2d2193bf8 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Thu, 16 Jun 2022 14:36:26 +0200 Subject: [PATCH 1/3] fix stacklevel of read_csv warning --- pandas/io/parsers/readers.py | 4 +--- pandas/tests/io/parser/common/test_common_basic.py | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/pandas/io/parsers/readers.py b/pandas/io/parsers/readers.py index 56df5493027c5..9af0d46f9a91d 100644 --- a/pandas/io/parsers/readers.py +++ b/pandas/io/parsers/readers.py @@ -829,9 +829,7 @@ def read_csv( ... -@deprecate_nonkeyword_arguments( - version=None, allowed_args=["filepath_or_buffer"], stacklevel=3 -) +@deprecate_nonkeyword_arguments(version=None, allowed_args=["filepath_or_buffer"]) @Appender( _doc_read_csv_and_table.format( func_name="read_csv", diff --git a/pandas/tests/io/parser/common/test_common_basic.py b/pandas/tests/io/parser/common/test_common_basic.py index 115a2976ce618..7f60fd60c91b0 100644 --- a/pandas/tests/io/parser/common/test_common_basic.py +++ b/pandas/tests/io/parser/common/test_common_basic.py @@ -806,8 +806,7 @@ def test_read_csv_posargs_deprecation(all_parsers): "In a future version of pandas all arguments of read_csv " "except for the argument 'filepath_or_buffer' will be keyword-only" ) - with tm.assert_produces_warning(FutureWarning, match=msg): - parser.read_csv(f, " ") + parser.read_csv_check_warnings(FutureWarning, msg, f, " ") @pytest.mark.parametrize("delimiter", [",", "\t"]) From e53e30cde5ebd1ea3cc201a062ab32981eac216b Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Fri, 24 Jun 2022 10:13:09 +0200 Subject: [PATCH 2/3] :doc: add whatsnewnote --- doc/source/whatsnew/v1.5.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index a5cb716317689..7aa9b9ec5fe83 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -177,6 +177,7 @@ Other enhancements - :class:`DataError`, :class:`SpecificationError`, :class:`SettingWithCopyError`, :class:`SettingWithCopyWarning`, :class:`NumExprClobberingError`, :class:`UndefinedVariableError`, and :class:`IndexingError` are now exposed in ``pandas.errors`` (:issue:`27656`) - Added ``check_like`` argument to :func:`testing.assert_series_equal` (:issue:`47247`) - Allow reading compressed SAS files with :func:`read_sas` (e.g., ``.sas7bdat.gz`` files) +- The :class:`errors.FutureWarning` raised when passing arguments (other than ``filepath_or_buffer``) as positional in :func:`read_csv` is now raised at the correct stacklevel (:issue:`47385`) .. --------------------------------------------------------------------------- .. _whatsnew_150.notable_bug_fixes: From f1d8d87ba1543cac0959a44172273fb27ba4383e Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Sat, 25 Jun 2022 13:38:31 +0200 Subject: [PATCH 3/3] move whatsnew entry to v1.4.4 --- doc/source/whatsnew/v1.4.4.rst | 2 +- doc/source/whatsnew/v1.5.0.rst | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v1.4.4.rst b/doc/source/whatsnew/v1.4.4.rst index b462f0c6a8ffe..ef9537200bccd 100644 --- a/doc/source/whatsnew/v1.4.4.rst +++ b/doc/source/whatsnew/v1.4.4.rst @@ -23,7 +23,7 @@ Fixed regressions Bug fixes ~~~~~~~~~ -- +- The :class:`errors.FutureWarning` raised when passing arguments (other than ``filepath_or_buffer``) as positional in :func:`read_csv` is now raised at the correct stacklevel (:issue:`47385`) - .. --------------------------------------------------------------------------- diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index 0dad1f46fac72..35594fbc8fb8a 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -256,7 +256,6 @@ Other enhancements - :class:`DataError`, :class:`SpecificationError`, :class:`SettingWithCopyError`, :class:`SettingWithCopyWarning`, :class:`NumExprClobberingError`, :class:`UndefinedVariableError`, and :class:`IndexingError` are now exposed in ``pandas.errors`` (:issue:`27656`) - Added ``check_like`` argument to :func:`testing.assert_series_equal` (:issue:`47247`) - Allow reading compressed SAS files with :func:`read_sas` (e.g., ``.sas7bdat.gz`` files) -- The :class:`errors.FutureWarning` raised when passing arguments (other than ``filepath_or_buffer``) as positional in :func:`read_csv` is now raised at the correct stacklevel (:issue:`47385`) .. --------------------------------------------------------------------------- .. _whatsnew_150.notable_bug_fixes: