Skip to content

Commit fa3c15a

Browse files
committed
Fixups for 3.13
1 parent 76a79ec commit fa3c15a

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Argument `include_module=False` for function `misc.tname()`.
1212
- New function `plotting.percentage_ticks()`
1313

14+
### Fixed
15+
- Handling of gh-101860 (new `@property.__name__`) under 3.13 in `misc.tname()` and `misc.get_public_module()`.
16+
1417
### Removed
1518
- Module `rics.ml.time_split`. use the `time-split` [![PyPI - Version](https://img.shields.io/pypi/v/time-split.svg)](https://pypi.python.org/pypi/time-split) package instead.
1619

src/rics/misc.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,25 +281,25 @@ def tname(
281281
def _get_name(arg: type[_t.Any] | _t.Any, prefix_classname: bool) -> str:
282282
if hasattr(arg, "__qualname__"):
283283
return arg.__qualname__ if prefix_classname else arg.__name__
284-
if hasattr(arg, "__name__"):
285-
return arg.__name__
286284
if hasattr(arg, "fget"):
287285
# Instance-level properties accessed using the class.
288286
return tname(arg.fget, prefix_classname=prefix_classname)
287+
if hasattr(arg, "__name__"):
288+
return arg.__name__
289289
if hasattr(arg, "__class__"):
290290
return arg.__class__.__qualname__ if prefix_classname else arg.__class__.__name__
291291
else:
292292
raise ValueError(f"Could not derive a name for {arg=}.") # pragma: no cover
293293

294294

295295
def _get_module(arg: type[_t.Any] | _t.Any) -> str:
296-
if hasattr(arg, "__name__"):
297-
obj = arg
298-
elif hasattr(arg, "__self__"):
299-
obj = arg.__self__
300-
elif hasattr(arg, "fget"):
296+
if hasattr(arg, "fget"):
301297
# Instance-level properties accessed using the class.
302298
obj = arg.fget
299+
elif hasattr(arg, "__self__"):
300+
obj = arg.__self__
301+
elif hasattr(arg, "__name__"):
302+
obj = arg
303303
else:
304304
obj = type(arg)
305305

tests/test_paths.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
from pathlib import Path
34

45
import pytest
@@ -58,7 +59,9 @@ def test_bad_type(self):
5859

5960
def test_bool(self):
6061
assert any_path_to_path(Path.home(), postprocessor=Path.is_dir) == Path.home()
61-
with pytest.raises(ValueError, match="Path.is_file"):
62+
63+
cls = "Path" if sys.version_info < (3, 13) else "PathBase"
64+
with pytest.raises(ValueError, match=f"{cls}.is_file"):
6265
any_path_to_path(Path.home(), postprocessor=Path.is_file)
6366

6467

0 commit comments

Comments
 (0)