From 513db52320e89efcdb36112846f32cc5eecad8fd Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Thu, 26 Dec 2024 12:27:44 -0500 Subject: [PATCH] misc: resolve deprecation warning for `str.split()` In Python 3.13, usage of a positional argument for `maxsplit` has been formally deprecated. Refs: https://github.com/python/cpython/pull/107778 Signed-off-by: Mike Fiedler --- newsfragments/+0ff2173d.misc.rst | 3 +++ pytest_postgresql/loader.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 newsfragments/+0ff2173d.misc.rst diff --git a/newsfragments/+0ff2173d.misc.rst b/newsfragments/+0ff2173d.misc.rst new file mode 100644 index 00000000..a93b2c5b --- /dev/null +++ b/newsfragments/+0ff2173d.misc.rst @@ -0,0 +1,3 @@ +In Python 3.13, usage of a positional argument for `maxsplit` has been +formally deprecated. +Update code to use keyword argument `maxsplit` instead of positional. diff --git a/pytest_postgresql/loader.py b/pytest_postgresql/loader.py index 9358d4dc..1b938313 100644 --- a/pytest_postgresql/loader.py +++ b/pytest_postgresql/loader.py @@ -13,7 +13,7 @@ def build_loader(load: Union[Callable, str, Path]) -> Callable: if isinstance(load, Path): return partial(sql, load) elif isinstance(load, str): - loader_parts = re.split("[.:]", load, 2) + loader_parts = re.split("[.:]", load, maxsplit=2) import_path = ".".join(loader_parts[:-1]) loader_name = loader_parts[-1] _temp_import = __import__(import_path, globals(), locals(), fromlist=[loader_name])