Skip to content

Commit de2e7fc

Browse files
committed
FIX: fixed warning message stack level on Python < 3.12
1 parent 5839dab commit de2e7fc

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

larray/core/axis.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from larray.util.misc import (duplicates, array_lookup2, ReprString, index_by_id, renamed_to, LHDFStore,
1818
lazy_attribute, _isnoneslice, unique_list, unique_multi, Product, argsort, has_duplicates,
1919
exactly_one, concatenate_ndarrays)
20-
from larray.util.misc import first, find_names
20+
from larray.util.misc import first, find_names, PY312_OR_LATER
2121
from larray.util.types import Scalar
2222

2323

@@ -2921,7 +2921,8 @@ def _guess_axis(self, axis_key):
29212921
# behavior, we must wait for a future release, and we
29222922
# only output a warning for now (see #1117)
29232923
# return axis_key.retarget_to(real_axis)
2924-
check_warn_retarget(axis_key, real_axis, stacklevel=8)
2924+
stack_level = 8 if PY312_OR_LATER else 9
2925+
check_warn_retarget(axis_key, real_axis, stacklevel=stack_level)
29252926
return axis_key.with_axis(real_axis)
29262927

29272928
real_axis, axis_pos_key = self._translate_nice_key(axis_key)

larray/core/group.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import sys
2-
31
import fnmatch
42
import re
53
import warnings
@@ -12,13 +10,13 @@
1210

1311
from larray.core.abstractbases import ABCAxis, ABCAxisReference, ABCArray
1412
from larray.util.oset import OrderedSet
15-
from larray.util.misc import (unique_list, find_closing_chr, _parse_bound, _seq_summary, _isintstring, renamed_to,
16-
LHDFStore)
13+
from larray.util.misc import (
14+
unique_list, find_closing_chr, _parse_bound, _seq_summary, _isintstring,
15+
renamed_to, LHDFStore, PY312_OR_LATER
16+
)
1717
from larray.util.types import Scalar, Key
1818

1919

20-
PY312_OR_LATER = sys.version_info[:2] >= (3, 12)
21-
2220
def _slice_to_str(key: slice, repr_func=str) -> str:
2321
r"""
2422
Convert a slice to a string.

larray/util/misc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,3 +1130,6 @@ def find_names(obj, depth=0):
11301130
if any(not name.startswith('_') for name in names):
11311131
names = [name for name in names if not name.startswith('_')]
11321132
return sorted(names)
1133+
1134+
1135+
PY312_OR_LATER = sys.version_info[:2] >= (3, 12)

0 commit comments

Comments
 (0)