Stacklevel argument updated #46687
- [x] closes #46687 
- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [x] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.

Can you suggest me some test to write for these? currently failing with
```
ImportError while loading conftest 'D:\a\pandas\pandas\pandas\conftest.py'.
pandas\__init__.py:48: in <module>
    from pandas.core.api import (
pandas\core\api.py:48: in <module>
    from pandas.core.groupby import (
pandas\core\groupby\__init__.py:1: in <module>
    from pandas.core.groupby.generic import (
pandas\core\groupby\generic.py:73: in <module>
    from pandas.core.frame import DataFrame
pandas\core\frame.py:202: in <module>
    from pandas.core.series import Series
pandas\core\series.py:5865: in <module>
    Series._add_numeric_operations()
pandas\core\generic.py:10950: in _add_numeric_operations
    @deprecate_nonkeyword_arguments(
E   TypeError: deprecate_nonkeyword_arguments() got an unexpected keyword argument 'stacklevel'
``` Hey @MarcoGorelli I tried changing the files and ran conftest.py to check, but getting errors like `AttributeError: module 'pandas._testing' has no attribute 'make_rand_series'` so not able to check the changes I have made. What can I do? hey @Anupam-USP - what command did you run that gave you that output?

You might need to re-compile the C extensions (`python setup.py build_ext -j 4`) To overcome the aforementioned issue, I have to still declare it as I did previously.  @Anupam-USP what's new entry not needed as this is not public (i removed it) couple of test failures, I'll take a look later

```
=================================== FAILURES ===================================
__________________ test_read_csv_posargs_deprecation[pyarrow] __________________
[gw0] linux -- Python 3.8.13 /usr/share/miniconda/envs/test/bin/python
all_parsers = <pandas.tests.io.parser.conftest.PyArrowParser object at 0x7f33cf300970>
    def test_read_csv_posargs_deprecation(all_parsers):
        # GH 41485
        f = StringIO("a,b\n1,2")
        parser = all_parsers
        msg = (
            "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, " ")
pandas/tests/io/parser/common/test_common_basic.py:810: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/share/miniconda/envs/test/lib/python3.8/contextlib.py:120: in __exit__
    next(self.gen)
pandas/_testing/_warnings.py:135: in _assert_caught_expected_warning
    _assert_raised_with_correct_stacklevel(actual_warning)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
actual_warning = <warnings.WarningMessage object at 0x7f33cd100820>
    def _assert_raised_with_correct_stacklevel(
        actual_warning: warnings.WarningMessage,
    ) -> None:
        from inspect import (
            getframeinfo,
            stack,
        )
        caller = getframeinfo(stack()[4][0])
        msg = (
            "Warning not set with correct stacklevel. "
            f"File where warning is raised: {actual_warning.filename} != "
            f"{caller.filename}. Warning message: {actual_warning.message}"
        )
>       assert actual_warning.filename == caller.filename, msg
E       AssertionError: Warning not set with correct stacklevel. File where warning is raised: /home/runner/work/pandas/pandas/pandas/tests/io/parser/conftest.py != /home/runner/work/pandas/pandas/pandas/tests/io/parser/common/test_common_basic.py. Warning message: In a future version of pandas all arguments of read_csv except for the argument 'filepath_or_buffer' will be keyword-only.
pandas/_testing/_warnings.py:221: AssertionError
_________________ test_read_table_posargs_deprecation[pyarrow] _________________
[gw0] linux -- Python 3.8.13 /usr/share/miniconda/envs/test/bin/python
all_parsers = <pandas.tests.io.parser.conftest.PyArrowParser object at 0x7f33d4eab5e0>
    def test_read_table_posargs_deprecation(all_parsers):
        # https://github.com/pandas-dev/pandas/issues/41485
        data = StringIO("a\tb\n1\t2")
        parser = all_parsers
        msg = (
            "In a future version of pandas all arguments of read_table "
            "except for the argument 'filepath_or_buffer' will be keyword-only"
        )
        with tm.assert_produces_warning(FutureWarning, match=msg):
>           parser.read_table(data, " ")
pandas/tests/io/parser/common/test_common_basic.py:925: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/share/miniconda/envs/test/lib/python3.8/contextlib.py:120: in __exit__
    next(self.gen)
pandas/_testing/_warnings.py:135: in _assert_caught_expected_warning
    _assert_raised_with_correct_stacklevel(actual_warning)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
actual_warning = <warnings.WarningMessage object at 0x7f33d4eab[52](https://github.com/pandas-dev/pandas/runs/6895416344?check_suite_focus=true#step:8:54)0>
    def _assert_raised_with_correct_stacklevel(
        actual_warning: warnings.WarningMessage,
    ) -> None:
        from inspect import (
            getframeinfo,
            stack,
        )
        caller = getframeinfo(stack()[4][0])
        msg = (
            "Warning not set with correct stacklevel. "
            f"File where warning is raised: {actual_warning.filename} != "
            f"{caller.filename}. Warning message: {actual_warning.message}"
        )
>       assert actual_warning.filename == caller.filename, msg
E       AssertionError: Warning not set with correct stacklevel. File where warning is raised: /home/runner/work/pandas/pandas/pandas/tests/io/parser/conftest.py != /home/runner/work/pandas/pandas/pandas/tests/io/parser/common/test_common_basic.py. Warning message: In a future version of pandas all arguments of read_table except for the argument 'filepath_or_buffer' will be keyword-only.
pandas/_testing/_warnings.py:221: AssertionError
=============================== warnings summary ===============================
pandas/tests/io/parser/test_parse_dates.py::test_date_parser_resolution_if_not_ns[pyarrow]
  /home/runner/work/pandas/pandas/pandas/tests/io/parser/conftest.py:29: FutureWarning: 
          Use pd.to_datetime instead.
    return read_csv(*args, **kwargs)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
------ generated xml file: /home/runner/work/pandas/pandas/test-data.xml -------
---------- coverage: platform linux, python 3.8.13-final-0 -----------
Coverage XML written to file coverage.xml
``` As noted here https://github.com/pandas-dev/pandas/issues/47385 , I think the test failure might be a false-positive. Will try to address that one first Thanks @Anupam-USP and @MarcoGorelli 