pandas
pandas copied to clipboard
WARN,TST check stacklevel for all warnings
- [ ] closes #47919 (Replace xxxx with the Github issue number)
- [ ] Tests added and passed if fixing a bug or adding a new feature
- [ ] All code checks passed.
- [ ] Added type annotations to new arguments/methods/functions.
- [ ] Added an entry in the latest
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.
Should be possible eventually, but at the moment there are some places where it needs setting manually for it to work, e.g.
https://github.com/pandas-dev/pandas/blob/a6aaeb6baf679fe133e968e0f65199fc56d177b2/pandas/compat/pickle_compat.py#L108
It looks like there, the going back up the frames temporarily brings us into the standard library:
(Pdb) frame
<frame at 0x7f87356b1b20, file '/home/marco/pandas-marco/pandas/compat/pickle_compat.py', line 92, code __new__>
(Pdb) p frame.f_back
<frame at 0x7f873569f7c0, file '/home/marco/pandas-marco/pandas/compat/pickle_compat.py', line 231, code load_newobj>
(Pdb) p frame.f_back.f_back
<frame at 0x7f87356b3640, file '/home/marco/miniconda3/envs/pandas-dev/lib/python3.8/pickle.py', line 1212, code load>
(Pdb) p frame.f_back.f_back
<frame at 0x7f87356b3640, file '/home/marco/miniconda3/envs/pandas-dev/lib/python3.8/pickle.py', line 1212, code load>
(Pdb) p frame.f_back.f_back.f_back
<frame at 0x7f8735765800, file '/home/marco/pandas-marco/pandas/compat/pickle_compat.py', line 277, code load>
(Pdb) p frame.f_back.f_back.f_back.f_back
<frame at 0x7f87356a6c40, file '/home/marco/pandas-marco/pandas/io/pickle.py', line 213, code read_pickle>
(Pdb) p frame.f_back.f_back.f_back.f_back.f_back
<frame at 0x7f873569f400, file '/home/marco/pandas-marco/pandas/tests/io/test_pickle.py', line 240, code test_legacy_sparse_warning>
, I'll have a look at what can be done about that
Any places where the stacklevel isn't correct should now be caught by the tests anyway, as with this PR it'd be checked for all warnings and check_stacklevel=True
is the default
Thanks for confirming. In any case, a check can be made in a follow up