Skip to content

Commit

Permalink
Clean up logic in stacklevel calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Apr 19, 2023
1 parent 10a54da commit 6863f53
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions python/lsst/daf/butler/core/datasets/ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,16 @@ def _find_outside_stacklevel() -> int:
stacklevel = 1
for i, s in enumerate(inspect.stack()):
module = inspect.getmodule(s.frame)
# Stack frames sometimes hang around so explicitly delete.
del s
if module is None:
# Stack frames sometimes hang around so explicilty delete.
del s
continue

Check warning on line 79 in python/lsst/daf/butler/core/datasets/ref.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/daf/butler/core/datasets/ref.py#L79

Added line #L79 was not covered by tests
if not module.__name__.startswith("lsst.daf.butler"):
# 0 will be this function.
# 1 will be the caller
# and so does not need adjustment.
stacklevel = i
break
# Stack frames sometimes hang around so explicitly delete.
del s

return stacklevel

Expand Down

0 comments on commit 6863f53

Please sign in to comment.