-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: stacklevel=2
makes all warnings look like they're coming from docval
#1164
Comments
Thanks for the issue @sneakers-the-rat . I agree that that particular warning is at the wrong place and should probably have For the cached namespace warning, with
With
Neither is very useful. There is no good way to show the line in user code (e.g., But for other cases where the user calls the function more directly, e.g., Lines 890 to 898 in a98e5e9
hdmf/src/hdmf/backends/hdf5/h5_utils.py Line 527 in a98e5e9
I think the stacklevel should be 3 (or whatever it takes to get to user code). Related tangentShowing lines outside of HDMF is possible with the new With
Now the warning is showing a line from pynwb. Still not ideal, and while we could also skip pynwb file prefixes, we should not add references to pynwb in hdmf. |
agreed :) you know better than I which functions/methods are called directly or not! ooooo i hadn't seen that that's super useful. |
What happened?
Trying to figure out how namespace caching works, loaded a NWB file using an old version of NWB, and got some warnings about a cached namespace already being loaded, but they were being raised from the
docval
generator.I think basically all of these warnings for methods/functions that are wrapped in
docval
should bestacklevel=1
so it's possible to find where they're being raised:eg.
Setting
stacklevel>1
is for when the warning is raised in the body of a wrapping function itselfSteps to Reproduce
Traceback
Operating System
macOS
Python Executable
Python
Python Version
3.11
Package Versions
pynwb: 2.8.1
hdmf: 3.14.3
The text was updated successfully, but these errors were encountered: