Coverage for python/lsst/utils/get_caller_name.py: 83%
Shortcuts on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of utils.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# Use of this source code is governed by a 3-clause BSD-style
10# license that can be found in the LICENSE file.
12__all__ = ["get_caller_name"]
14from deprecated.sphinx import deprecated
15from .introspection import get_caller_name as caller_name
18@deprecated(reason="get_caller_name has moved to `lsst.utils.introspection.get_caller_name`."
19 " Will be removed in v26.",
20 version="v24", category=FutureWarning)
21def get_caller_name(skip: int = 2) -> str:
22 """Get the name of the caller method.
24 Any item that cannot be determined (or is not relevant, e.g. a free
25 function has no class) is silently omitted, along with an
26 associated separator.
28 Parameters
29 ----------
30 skip : `int`
31 How many levels of stack to skip while getting caller name;
32 1 means "who calls me", 2 means "who calls my caller", etc.
34 Returns
35 -------
36 name : `str`
37 Name of the caller as a string in the form ``module.class.method``.
38 An empty string is returned if ``skip`` exceeds the stack height.
39 """
40 # Offset the stack level to account for redirect and deprecated wrapper.
41 return caller_name(stacklevel=skip + 2)